Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add changeset config for cli & fixes #12

Merged
merged 8 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,7 @@ yarn-error.log*
Thumbs.db

# Typescript
*.tsbuildinfo
*.tsbuildinfo

# cli changesets
apps/cli/.changeset/*.md
15 changes: 15 additions & 0 deletions apps/cli/.changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json",
"changelog": [
"@changesets/changelog-github",
{ "repo": "labscommunity/starterkit" }
],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["web"],
"changedFilePatterns": ["src/**", "template/**"]
}
2 changes: 0 additions & 2 deletions apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@
"validate-npm-package-name": "^5.0.0"
},
"devDependencies": {
"@types/figlet": "^1.5.7",
"@types/fs-extra": "^11.0.1",
"@types/inquirer": "^9.0.3",
"@types/node": "^18.16.0",
"@types/validate-npm-package-name": "^4.0.1",
"@typescript-eslint/eslint-plugin": "^6.8.0",
Expand Down
20 changes: 17 additions & 3 deletions apps/cli/src/helpers/installDependencies.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import chalk from "chalk";
import { execa, type StdioOption } from "execa";
import ora, { type Ora } from "ora";
import path from "path";
import fs from "fs-extra";

import { getUserPkgManager, type PackageManager } from "@/utils/getUserPkgManager.js";
import { logger } from "@/utils/logger.js";
Expand Down Expand Up @@ -70,7 +72,19 @@ export const installDependencies = async ({ projectDir }: { projectDir: string }

const installSpinner = await runInstallCommand(pkgManager, projectDir);

// If the spinner was used to show the progress, use succeed method on it
// If not, use the succeed on a new spinner
(installSpinner ?? ora()).succeed(chalk.green("Successfully installed dependencies!\n"));
const isDependenciesInstalled = fs.existsSync(path.join(projectDir, "node_modules"));
if (isDependenciesInstalled) {
// If the spinner was used to show the progress, use succeed method on it
// If not, use the succeed on a new spinner
(installSpinner ?? ora()).succeed(chalk.green("Successfully installed dependencies!\n"));
return false;
} else {
(installSpinner ?? ora()).fail(
chalk.red(
"Failed to install dependencies! Please refer to https://github.com/labscommunity/starterkit#getting-started for troubleshooting steps to resolve this issue.\n"
)
);

return true;
}
};
11 changes: 9 additions & 2 deletions apps/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/usr/bin/env node

/**
* This CLI integrates contributions and portions of code sourced from various repositories.
* For a complete list of contributions and credits, please see https://github.com/labscommunity/starterkit/blob/main/CREDITS.md.
*/

import path from "path";
import { execa } from "execa";
import fs from "fs-extra";
Expand Down Expand Up @@ -79,8 +85,9 @@ const main = async () => {
setImportAlias(projectDir, importAlias);
}

let showInstallCommand = noInstall;
if (!noInstall) {
await installDependencies({ projectDir });
showInstallCommand = await installDependencies({ projectDir });
}

// Rename _eslintrc.json to .eslintrc.json - we use _eslintrc.json to avoid conflicts with the monorepos linter
Expand All @@ -92,7 +99,7 @@ const main = async () => {

await logNextSteps({
projectName: appDir,
noInstall,
noInstall: showInstallCommand,
projectDir,
});

Expand Down
2 changes: 1 addition & 1 deletion apps/cli/template/next/javascript/src/app/layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function RootLayout({ children }) {
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
<ArweaveWalletKit
config={{
permissions: ["ACCESS_ADDRESS", "SIGN_TRANSACTION", "DISPATCH", "ACCESS_PUBLIC_KEY", "SIGNATURE"],
permissions: ["ACCESS_ADDRESS", "SIGN_TRANSACTION", "DISPATCH"],
ensurePermissions: true,
appInfo: {
name: "StarterKit",
Expand Down
4 changes: 1 addition & 3 deletions apps/cli/template/next/javascript/src/components/assets.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"use client";

import { AssetCard } from "@/components/asset-card";
import { useUser } from "@/hooks/useUser";
import { getAssetData } from "@/lib/query-assets";
import * as React from "react";

export function Assets() {
const { connected, address } = useUser();
const [assets, setAssets] = React.useState([]);

React.useEffect(() => {
Expand All @@ -15,7 +13,7 @@ export function Assets() {
setAssets(data);
}
fetchData();
}, [connected, address]);
}, []);

return (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 w-full gap-6">
Expand Down
14 changes: 8 additions & 6 deletions apps/cli/template/next/javascript/src/components/stamp-like.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async function getStamps() {
}

export function Stamp(props) {
const { connected } = useUser();
const { connected, address } = useUser();
const [stampCount, setStampCount] = React.useState(0);
const [hasStamped, setHasStamped] = React.useState(false);

Expand All @@ -41,14 +41,16 @@ export function Stamp(props) {
async function fetchStampData() {
const stamps = await getStamps();
const { total } = await stamps.count(props.txId);
const stampedStatus = await stamps.hasStamped(props.txId);

setStampCount(total);
setHasStamped(stampedStatus);

if (address) {
const stampedStatus = await stamps.hasStamped(props.txId);
setHasStamped(stampedStatus);
}
}

fetchStampData();
}, [props.txId]);
}, [props.txId, address]);

return (
<HoverCard>
Expand All @@ -59,7 +61,7 @@ export function Stamp(props) {
disabled={!connected || hasStamped}
className={`
transition
${hasStamped ? "text-red-500" : ""}
${hasStamped && connected ? "text-red-500" : ""}
${!hasStamped && connected ? "hover:text-red-500" : ""}
`}
>
Expand Down
2 changes: 1 addition & 1 deletion apps/cli/template/next/javascript/src/pages/_app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function App({ Component, pageProps }) {
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
<ArweaveWalletKit
config={{
permissions: ["ACCESS_ADDRESS", "SIGN_TRANSACTION", "DISPATCH", "ACCESS_PUBLIC_KEY", "SIGNATURE"],
permissions: ["ACCESS_ADDRESS", "SIGN_TRANSACTION", "DISPATCH"],
ensurePermissions: true,
appInfo: {
name: "StarterKit",
Expand Down
8 changes: 1 addition & 7 deletions apps/cli/template/next/typescript/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,7 @@ export default function RootLayout({ children }: RootLayoutProps) {
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
<ArweaveWalletKit
config={{
permissions: [
"ACCESS_ADDRESS",
"SIGN_TRANSACTION",
"DISPATCH",
"ACCESS_PUBLIC_KEY",
"SIGNATURE",
],
permissions: ["ACCESS_ADDRESS", "SIGN_TRANSACTION", "DISPATCH"],
ensurePermissions: true,
appInfo: {
name: "StarterKit",
Expand Down
3 changes: 1 addition & 2 deletions apps/cli/template/next/typescript/src/components/assets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { QueriedAsset } from "@/types/query";
import * as React from "react";

export function Assets() {
const { connected, address } = useUser();
const [assets, setAssets] = React.useState<QueriedAsset[]>([]);

React.useEffect(() => {
Expand All @@ -16,7 +15,7 @@ export function Assets() {
setAssets(data);
}
fetchData();
}, [connected, address]);
}, []);

return (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 w-full gap-6">
Expand Down
14 changes: 8 additions & 6 deletions apps/cli/template/next/typescript/src/components/stamp-like.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface StampProps {
}

export function Stamp(props: StampProps) {
const { connected } = useUser();
const { connected, address } = useUser();
const [stampCount, setStampCount] = React.useState<number>(0);
const [hasStamped, setHasStamped] = React.useState<boolean>(false);

Expand All @@ -49,14 +49,16 @@ export function Stamp(props: StampProps) {
async function fetchStampData() {
const stamps = await getStamps();
const { total } = await stamps.count(props.txId);
const stampedStatus = await stamps.hasStamped(props.txId);

setStampCount(total);
setHasStamped(stampedStatus);

if (address) {
const stampedStatus = await stamps.hasStamped(props.txId);
setHasStamped(stampedStatus);
}
}

fetchStampData();
}, [props.txId]);
}, [props.txId, address]);

return (
<HoverCard>
Expand All @@ -67,7 +69,7 @@ export function Stamp(props: StampProps) {
disabled={!connected || hasStamped}
className={`
transition
${hasStamped ? "text-red-500" : ""}
${hasStamped && connected ? "text-red-500" : ""}
${!hasStamped && connected ? "hover:text-red-500" : ""}
`}
>
Expand Down
8 changes: 1 addition & 7 deletions apps/cli/template/next/typescript/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ export default function App({ Component, pageProps }: AppProps) {
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
<ArweaveWalletKit
config={{
permissions: [
"ACCESS_ADDRESS",
"SIGN_TRANSACTION",
"DISPATCH",
"ACCESS_PUBLIC_KEY",
"SIGNATURE",
],
permissions: ["ACCESS_ADDRESS", "SIGN_TRANSACTION", "DISPATCH"],
ensurePermissions: true,
appInfo: {
name: "StarterKit",
Expand Down
8 changes: 1 addition & 7 deletions apps/web/src/_pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ export default function App({ Component, pageProps }: AppProps) {
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
<ArweaveWalletKit
config={{
permissions: [
"ACCESS_ADDRESS",
"SIGN_TRANSACTION",
"DISPATCH",
"ACCESS_PUBLIC_KEY",
"SIGNATURE",
],
permissions: ["ACCESS_ADDRESS", "SIGN_TRANSACTION", "DISPATCH"],
ensurePermissions: true,
appInfo: {
name: "StarterKit",
Expand Down
8 changes: 1 addition & 7 deletions apps/web/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,7 @@ export default function RootLayout({ children }: RootLayoutProps) {
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
<ArweaveWalletKit
config={{
permissions: [
"ACCESS_ADDRESS",
"SIGN_TRANSACTION",
"DISPATCH",
"ACCESS_PUBLIC_KEY",
"SIGNATURE",
],
permissions: ["ACCESS_ADDRESS", "SIGN_TRANSACTION", "DISPATCH"],
ensurePermissions: true,
appInfo: {
name: "StarterKit",
Expand Down
3 changes: 1 addition & 2 deletions apps/web/src/components/assets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { QueriedAsset } from "@/types/query";
import * as React from "react";

export function Assets() {
const { connected, address } = useUser();
const [assets, setAssets] = React.useState<QueriedAsset[]>([]);

React.useEffect(() => {
Expand All @@ -16,7 +15,7 @@ export function Assets() {
setAssets(data);
}
fetchData();
}, [connected, address]);
}, []);

return (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 w-full gap-6">
Expand Down
14 changes: 8 additions & 6 deletions apps/web/src/components/stamp-like.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface StampProps {
}

export function Stamp(props: StampProps) {
const { connected } = useUser();
const { connected, address } = useUser();
const [stampCount, setStampCount] = React.useState<number>(0);
const [hasStamped, setHasStamped] = React.useState<boolean>(false);

Expand All @@ -49,14 +49,16 @@ export function Stamp(props: StampProps) {
async function fetchStampData() {
const stamps = await getStamps();
const { total } = await stamps.count(props.txId);
const stampedStatus = await stamps.hasStamped(props.txId);

setStampCount(total);
setHasStamped(stampedStatus);

if (address) {
const stampedStatus = await stamps.hasStamped(props.txId);
setHasStamped(stampedStatus);
}
}

fetchStampData();
}, [props.txId]);
}, [props.txId, address]);

return (
<HoverCard>
Expand All @@ -67,7 +69,7 @@ export function Stamp(props: StampProps) {
disabled={!connected || hasStamped}
className={`
transition
${hasStamped ? "text-red-500" : ""}
${hasStamped && connected ? "text-red-500" : ""}
${!hasStamped && connected ? "hover:text-red-500" : ""}
`}
>
Expand Down
Loading