From c15576898389acb41ad00efb222e5a3ea7f84c7c Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Thu, 28 Dec 2023 03:14:21 -0600 Subject: [PATCH 01/17] feat(create-waku): bundle into single file --- packages/create-waku/{src/cli.ts => index.ts} | 4 +-- packages/create-waku/package.json | 23 ++++++------ packages/create-waku/tsconfig.json | 4 +-- pnpm-lock.yaml | 36 +++++++++++-------- 4 files changed, 36 insertions(+), 31 deletions(-) rename packages/create-waku/{src/cli.ts => index.ts} (97%) diff --git a/packages/create-waku/src/cli.ts b/packages/create-waku/index.ts similarity index 97% rename from packages/create-waku/src/cli.ts rename to packages/create-waku/index.ts index c0cfc8907..c4d4c4a76 100644 --- a/packages/create-waku/src/cli.ts +++ b/packages/create-waku/index.ts @@ -1,9 +1,7 @@ #!/usr/bin/env node - import { existsSync, readdirSync } from 'node:fs'; import fsPromises from 'node:fs/promises'; import path from 'node:path'; -import { fileURLToPath } from 'node:url'; import { default as prompts } from 'prompts'; import { red, green, bold } from 'kolorist'; import fse from 'fs-extra/esm'; @@ -32,7 +30,7 @@ async function init() { let targetDir = ''; const defaultProjectName = 'waku-project'; - const templateRoot = fileURLToPath(new URL('../template', import.meta.url)); + const templateRoot = path.resolve(path.dirname(process.argv[1] as string), './template') const CHOICES = await fsPromises.readdir(templateRoot); let result: { packageName: string; diff --git a/packages/create-waku/package.json b/packages/create-waku/package.json index c592fb682..e161a3860 100644 --- a/packages/create-waku/package.json +++ b/packages/create-waku/package.json @@ -8,29 +8,28 @@ ], "repository": { "type": "git", - "url": "https://github.com/dai-shi/waku.git" + "url": "https://github.com/dai-shi/waku.git", + "directory": "packages/create-waku" }, "bin": { - "create-waku": "./dist/cli.js" + "create-waku": "./dist/index.js" }, "files": [ - "src", - "dist", - "template" + "dist" ], "scripts": { - "start": "node dist/cli.js", + "start": "node ./dist/index.js", + "dev": "ncc build ./index.ts -w -o ./dist/", "compile": "rm -rf template dist *.tsbuildinfo && pnpm run template && pnpm run build", "template": "cp -r ../../examples template/ && rm -rf template/*/dist && rm -rf template/*/node_modules", - "build": "tsc -b" + "build": "ncc build ./index.ts -o ./dist/ --minify --no-cache --no-source-map-register" }, - "dependencies": { + "devDependencies": { + "@types/fs-extra": "^11.0.4", + "@types/prompts": "^2.4.9", + "@vercel/ncc": "^0.38.1", "fs-extra": "^11.2.0", "kolorist": "^1.8.0", "prompts": "^2.4.2" - }, - "devDependencies": { - "@types/fs-extra": "^11.0.4", - "@types/prompts": "^2.4.9" } } diff --git a/packages/create-waku/tsconfig.json b/packages/create-waku/tsconfig.json index 42a2ce85a..113d1fe12 100644 --- a/packages/create-waku/tsconfig.json +++ b/packages/create-waku/tsconfig.json @@ -1,12 +1,12 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src", + "rootDir": ".", "outDir": "./dist", "lib": ["esnext"], "emitDeclarationOnly": false }, - "include": ["./src"], + "include": ["./index.ts"], "exclude": ["./template"], "references": [ { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 21128e6de..5f3c50ce2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -694,7 +694,16 @@ importers: version: 0.4.0(@babel/traverse@7.23.6)(@babel/types@7.23.6)(vite@5.0.9) packages/create-waku: - dependencies: + devDependencies: + '@types/fs-extra': + specifier: ^11.0.4 + version: 11.0.4 + '@types/prompts': + specifier: ^2.4.9 + version: 2.4.9 + '@vercel/ncc': + specifier: ^0.38.1 + version: 0.38.1 fs-extra: specifier: ^11.2.0 version: 11.2.0 @@ -704,13 +713,6 @@ importers: prompts: specifier: ^2.4.2 version: 2.4.2 - devDependencies: - '@types/fs-extra': - specifier: ^11.0.4 - version: 11.0.4 - '@types/prompts': - specifier: ^2.4.9 - version: 2.4.9 packages/waku: dependencies: @@ -2340,6 +2342,11 @@ packages: - ts-node dev: true + /@vercel/ncc@0.38.1: + resolution: {integrity: sha512-IBBb+iI2NLu4VQn3Vwldyi2QwaXt5+hTyh58ggAMoCGE6DJmPvwL3KPBWcJl1m9LYPChBLE980Jw+CS4Wokqxw==} + hasBin: true + dev: true + /@vitejs/plugin-react@4.2.1(vite@5.0.9): resolution: {integrity: sha512-oojO9IDc4nCUUi8qIR11KoQm0XFFLIwsRBwHRR4d/88IWghn1y6ckz/bJ8GHDCsYEJee8mDzqtJxh15/cisJNQ==} engines: {node: ^14.18.0 || >=16.0.0} @@ -3865,7 +3872,7 @@ packages: graceful-fs: 4.2.11 jsonfile: 6.1.0 universalify: 2.0.1 - dev: false + dev: true /fs.realpath@1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} @@ -4530,7 +4537,7 @@ packages: universalify: 2.0.1 optionalDependencies: graceful-fs: 4.2.11 - dev: false + dev: true /jsx-ast-utils@3.3.5: resolution: {integrity: sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==} @@ -4551,6 +4558,7 @@ packages: /kleur@3.0.3: resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==} engines: {node: '>=6'} + dev: true /kleur@4.1.5: resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} @@ -4559,7 +4567,7 @@ packages: /kolorist@1.8.0: resolution: {integrity: sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==} - dev: false + dev: true /levn@0.4.1: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} @@ -5623,7 +5631,7 @@ packages: dependencies: kleur: 3.0.3 sisteransi: 1.0.5 - dev: false + dev: true /prop-types@15.8.1: resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==} @@ -6079,7 +6087,7 @@ packages: /sisteransi@1.0.5: resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} - dev: false + dev: true /slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} @@ -6585,7 +6593,7 @@ packages: /universalify@2.0.1: resolution: {integrity: sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==} engines: {node: '>= 10.0.0'} - dev: false + dev: true /unpipe@1.0.0: resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==} From 2f86f833dfc93a88f8da02139cff39ed1574acc2 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Thu, 28 Dec 2023 03:44:45 -0600 Subject: [PATCH 02/17] test: add test case --- e2e/create-waku.spec.ts | 47 +++++++++++++++++++++++++++++++ packages/create-waku/index.ts | 11 ++++++-- packages/create-waku/package.json | 3 +- 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 e2e/create-waku.spec.ts diff --git a/e2e/create-waku.spec.ts b/e2e/create-waku.spec.ts new file mode 100644 index 000000000..25dd34daa --- /dev/null +++ b/e2e/create-waku.spec.ts @@ -0,0 +1,47 @@ +import { spawn } from 'node:child_process'; +import { fileURLToPath } from 'node:url'; +import crypto from 'node:crypto'; +import { mkdir, readdir } from 'node:fs/promises'; +import { test, debugChildProcess } from './utils.js'; +import { expect } from '@playwright/test'; + +test('should create waku with all enter work', async () => { + const cliPath = fileURLToPath( + new URL('../packages/create-waku/dist/index.js', import.meta.url), + ); + + const dirname = crypto.randomUUID(); + await mkdir(new URL(`./.cache/${dirname}/`, import.meta.url), { + recursive: true, + }); + const cwd = fileURLToPath(new URL(`./.cache/${dirname}`, import.meta.url)); + console.log(`Creating waku in ${cwd}`); + const cp = spawn(process.execPath, [cliPath], { + cwd, + env: process.env, + }); + debugChildProcess(cp); + const stdin = cp.stdin!; + await new Promise((resolve) => { + cp.stdout!.on('data', (data) => { + const str = data.toString(); + if (str.includes('Project Name')) { + stdin.write('\n'); // use default + } else if (str.includes('Choose a starter template')) { + stdin.write('\n'); // use default + } + if (str.includes('Done.')) { + resolve(); + } + }); + }); + const paths = await readdir(cwd); + expect(paths[0]).toBe('waku-project'); + expect(paths.length).toBe(1); + const files = await readdir( + new URL(`./.cache/${dirname}/waku-project`, import.meta.url), + ); + expect(files).toContain('package.json'); + expect(files).toContain('src'); + expect(files).toContain('tsconfig.json'); +}); diff --git a/packages/create-waku/index.ts b/packages/create-waku/index.ts index c4d4c4a76..13b2fc75d 100644 --- a/packages/create-waku/index.ts +++ b/packages/create-waku/index.ts @@ -5,6 +5,7 @@ import path from 'node:path'; import { default as prompts } from 'prompts'; import { red, green, bold } from 'kolorist'; import fse from 'fs-extra/esm'; +import * as console from 'console'; function isValidPackageName(projectName: string) { return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test( @@ -30,8 +31,14 @@ async function init() { let targetDir = ''; const defaultProjectName = 'waku-project'; - const templateRoot = path.resolve(path.dirname(process.argv[1] as string), './template') - const CHOICES = await fsPromises.readdir(templateRoot); + const templateRoot = path.resolve( + path.dirname(process.argv[1] as string), + '../template', + ); + // maybe include `.DS_Store` on macOS + const CHOICES = (await fsPromises.readdir(templateRoot)).filter( + (dir) => !dir.startsWith('.'), + ); let result: { packageName: string; shouldOverwrite: string; diff --git a/packages/create-waku/package.json b/packages/create-waku/package.json index e161a3860..074bbf51c 100644 --- a/packages/create-waku/package.json +++ b/packages/create-waku/package.json @@ -15,7 +15,8 @@ "create-waku": "./dist/index.js" }, "files": [ - "dist" + "dist", + "template" ], "scripts": { "start": "node ./dist/index.js", From 29e3734f8f5792766cbfbe607814aacba4bdff5a Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Thu, 28 Dec 2023 03:45:49 -0600 Subject: [PATCH 03/17] fix: naming --- e2e/create-waku.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/create-waku.spec.ts b/e2e/create-waku.spec.ts index 25dd34daa..9bf3ffd88 100644 --- a/e2e/create-waku.spec.ts +++ b/e2e/create-waku.spec.ts @@ -5,7 +5,7 @@ import { mkdir, readdir } from 'node:fs/promises'; import { test, debugChildProcess } from './utils.js'; import { expect } from '@playwright/test'; -test('should create waku with all enter work', async () => { +test('should create waku with default setup work', async () => { const cliPath = fileURLToPath( new URL('../packages/create-waku/dist/index.js', import.meta.url), ); From 856c013c786122d176dd018838145dbeff379040 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Thu, 28 Dec 2023 03:57:09 -0600 Subject: [PATCH 04/17] fix: dirname --- packages/create-waku/index.ts | 10 ++++------ packages/create-waku/package.json | 3 +-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/create-waku/index.ts b/packages/create-waku/index.ts index 13b2fc75d..79b001502 100644 --- a/packages/create-waku/index.ts +++ b/packages/create-waku/index.ts @@ -1,11 +1,12 @@ #!/usr/bin/env node import { existsSync, readdirSync } from 'node:fs'; import fsPromises from 'node:fs/promises'; -import path from 'node:path'; +import path, { dirname } from 'node:path'; import { default as prompts } from 'prompts'; import { red, green, bold } from 'kolorist'; import fse from 'fs-extra/esm'; import * as console from 'console'; +import { fileURLToPath } from 'node:url'; function isValidPackageName(projectName: string) { return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test( @@ -30,11 +31,8 @@ function canSafelyOverwrite(dir: string) { async function init() { let targetDir = ''; const defaultProjectName = 'waku-project'; - - const templateRoot = path.resolve( - path.dirname(process.argv[1] as string), - '../template', - ); + const __dirname = dirname(fileURLToPath(import.meta.url)); + const templateRoot = path.resolve(__dirname, './template'); // maybe include `.DS_Store` on macOS const CHOICES = (await fsPromises.readdir(templateRoot)).filter( (dir) => !dir.startsWith('.'), diff --git a/packages/create-waku/package.json b/packages/create-waku/package.json index 074bbf51c..e161a3860 100644 --- a/packages/create-waku/package.json +++ b/packages/create-waku/package.json @@ -15,8 +15,7 @@ "create-waku": "./dist/index.js" }, "files": [ - "dist", - "template" + "dist" ], "scripts": { "start": "node ./dist/index.js", From 3dc5768aeb121b2132974a39c5fade79fba3b740 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Thu, 28 Dec 2023 04:00:34 -0600 Subject: [PATCH 05/17] fix: build create-waku --- e2e/create-waku.spec.ts | 1 - scripts/postinstall.js | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/e2e/create-waku.spec.ts b/e2e/create-waku.spec.ts index 9bf3ffd88..d4a71c998 100644 --- a/e2e/create-waku.spec.ts +++ b/e2e/create-waku.spec.ts @@ -15,7 +15,6 @@ test('should create waku with default setup work', async () => { recursive: true, }); const cwd = fileURLToPath(new URL(`./.cache/${dirname}`, import.meta.url)); - console.log(`Creating waku in ${cwd}`); const cp = spawn(process.execPath, [cliPath], { cwd, env: process.env, diff --git a/scripts/postinstall.js b/scripts/postinstall.js index e01e93983..84d61de53 100755 --- a/scripts/postinstall.js +++ b/scripts/postinstall.js @@ -20,3 +20,17 @@ if (!fs.existsSync(directory)) { process.exit(1); } } + +if (!fs.existsSync('./packages/create-waku/dist')) { + try { + execSync('pnpm -r --filter="./packages/create-waku" run compile', { + stdio: 'inherit', + }); + } catch (error) { + console.error( + 'An error occurred while running postinstall scripts:', + error, + ); + process.exit(1); + } +} From fdbb8f9a1053b484589a1e8ec5642b8c586601ae Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Thu, 28 Dec 2023 04:06:37 -0600 Subject: [PATCH 06/17] Revert "fix: build create-waku" This reverts commit 3dc5768aeb121b2132974a39c5fade79fba3b740. --- e2e/create-waku.spec.ts | 1 + scripts/postinstall.js | 14 -------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/e2e/create-waku.spec.ts b/e2e/create-waku.spec.ts index d4a71c998..9bf3ffd88 100644 --- a/e2e/create-waku.spec.ts +++ b/e2e/create-waku.spec.ts @@ -15,6 +15,7 @@ test('should create waku with default setup work', async () => { recursive: true, }); const cwd = fileURLToPath(new URL(`./.cache/${dirname}`, import.meta.url)); + console.log(`Creating waku in ${cwd}`); const cp = spawn(process.execPath, [cliPath], { cwd, env: process.env, diff --git a/scripts/postinstall.js b/scripts/postinstall.js index 84d61de53..e01e93983 100755 --- a/scripts/postinstall.js +++ b/scripts/postinstall.js @@ -20,17 +20,3 @@ if (!fs.existsSync(directory)) { process.exit(1); } } - -if (!fs.existsSync('./packages/create-waku/dist')) { - try { - execSync('pnpm -r --filter="./packages/create-waku" run compile', { - stdio: 'inherit', - }); - } catch (error) { - console.error( - 'An error occurred while running postinstall scripts:', - error, - ); - process.exit(1); - } -} From cb25d03b7d343ef389d3dd3d5dd093ee8ab24296 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Thu, 28 Dec 2023 04:09:20 -0600 Subject: [PATCH 07/17] ci: fix --- .github/workflows/ci.yml | 22 ++++++++++++++++++++++ e2e/create-waku.spec.ts | 1 - 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f19cdbde1..cbb47f97f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,24 @@ jobs: - run: pnpm install --frozen-lockfile - run: pnpm test + build-create-waku: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: pnpm/action-setup@v2 + - uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'pnpm' + cache-dependency-path: '**/pnpm-lock.yaml' + - run: pnpm install --frozen-lockfile + - run: pnpm -r --filter="./packages/create-waku" run compile + - uses: actions/upload-artifact@v4 + with: + name: create-waku + path: packages/create-waku/dist + if-no-files-found: error + e2e: name: E2E on ${{ matrix.os }} (Node ${{ matrix.version }}) - (${{ matrix.shared }}/4) strategy: @@ -41,6 +59,10 @@ jobs: node-version: ${{ matrix.version }} cache: 'pnpm' cache-dependency-path: '**/pnpm-lock.yaml' + - uses: actions/download-artifact@v4 + with: + name: create-waku + path: packages/create-waku/dist - run: pnpm install --frozen-lockfile - run: pnpm run compile - name: Cache Playwright diff --git a/e2e/create-waku.spec.ts b/e2e/create-waku.spec.ts index 9bf3ffd88..d4a71c998 100644 --- a/e2e/create-waku.spec.ts +++ b/e2e/create-waku.spec.ts @@ -15,7 +15,6 @@ test('should create waku with default setup work', async () => { recursive: true, }); const cwd = fileURLToPath(new URL(`./.cache/${dirname}`, import.meta.url)); - console.log(`Creating waku in ${cwd}`); const cp = spawn(process.execPath, [cliPath], { cwd, env: process.env, From 07de3cf8b4e3a7bf5d66e59cb885176e186322e3 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Thu, 28 Dec 2023 04:10:08 -0600 Subject: [PATCH 08/17] ci: fix --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cbb47f97f..6d656a77d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,6 +44,8 @@ jobs: e2e: name: E2E on ${{ matrix.os }} (Node ${{ matrix.version }}) - (${{ matrix.shared }}/4) + needs: + - build-create-waku strategy: fail-fast: false matrix: From 1bc0fcb5f84cf67c07602290734b1f54bb23a4c9 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Thu, 28 Dec 2023 04:13:03 -0600 Subject: [PATCH 09/17] fix: template --- packages/create-waku/index.ts | 2 +- packages/create-waku/package.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/create-waku/index.ts b/packages/create-waku/index.ts index 79b001502..4095de7a8 100644 --- a/packages/create-waku/index.ts +++ b/packages/create-waku/index.ts @@ -32,7 +32,7 @@ async function init() { let targetDir = ''; const defaultProjectName = 'waku-project'; const __dirname = dirname(fileURLToPath(import.meta.url)); - const templateRoot = path.resolve(__dirname, './template'); + const templateRoot = path.resolve(__dirname, '../template'); // maybe include `.DS_Store` on macOS const CHOICES = (await fsPromises.readdir(templateRoot)).filter( (dir) => !dir.startsWith('.'), diff --git a/packages/create-waku/package.json b/packages/create-waku/package.json index e161a3860..074bbf51c 100644 --- a/packages/create-waku/package.json +++ b/packages/create-waku/package.json @@ -15,7 +15,8 @@ "create-waku": "./dist/index.js" }, "files": [ - "dist" + "dist", + "template" ], "scripts": { "start": "node ./dist/index.js", From edffd50c972a7fe16bdfadc00f18edf44c0819ad Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Thu, 28 Dec 2023 04:16:14 -0600 Subject: [PATCH 10/17] fix: console --- packages/create-waku/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/create-waku/index.ts b/packages/create-waku/index.ts index 4095de7a8..9d75aa8aa 100644 --- a/packages/create-waku/index.ts +++ b/packages/create-waku/index.ts @@ -5,7 +5,6 @@ import path, { dirname } from 'node:path'; import { default as prompts } from 'prompts'; import { red, green, bold } from 'kolorist'; import fse from 'fs-extra/esm'; -import * as console from 'console'; import { fileURLToPath } from 'node:url'; function isValidPackageName(projectName: string) { From 645f022e174a98d1a843982d65f774967a56821b Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Thu, 28 Dec 2023 04:27:59 -0600 Subject: [PATCH 11/17] ci: fix --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d656a77d..8d1e5ef10 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: - uses: actions/upload-artifact@v4 with: name: create-waku - path: packages/create-waku/dist + path: packages/create-waku if-no-files-found: error e2e: @@ -64,7 +64,7 @@ jobs: - uses: actions/download-artifact@v4 with: name: create-waku - path: packages/create-waku/dist + path: packages/create-waku - run: pnpm install --frozen-lockfile - run: pnpm run compile - name: Cache Playwright From ed4dd958ce34cc5608cb1a2c24452293d6155d35 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Thu, 28 Dec 2023 17:48:34 -0600 Subject: [PATCH 12/17] ci: improve --- packages/create-waku/package.json | 8 ++++---- packages/create-waku/{index.ts => src/cli.ts} | 0 packages/create-waku/tsconfig.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) rename packages/create-waku/{index.ts => src/cli.ts} (100%) diff --git a/packages/create-waku/package.json b/packages/create-waku/package.json index 074bbf51c..daa5db42e 100644 --- a/packages/create-waku/package.json +++ b/packages/create-waku/package.json @@ -12,18 +12,18 @@ "directory": "packages/create-waku" }, "bin": { - "create-waku": "./dist/index.js" + "create-waku": "./dist/cli.js" }, "files": [ "dist", "template" ], "scripts": { - "start": "node ./dist/index.js", - "dev": "ncc build ./index.ts -w -o ./dist/", + "start": "node ./dist/cli.js", + "dev": "ncc build ./src/cli.ts -w -o ./dist/", "compile": "rm -rf template dist *.tsbuildinfo && pnpm run template && pnpm run build", "template": "cp -r ../../examples template/ && rm -rf template/*/dist && rm -rf template/*/node_modules", - "build": "ncc build ./index.ts -o ./dist/ --minify --no-cache --no-source-map-register" + "build": "ncc build ./src/cli.ts -o ./dist/ --minify --no-cache --no-source-map-register" }, "devDependencies": { "@types/fs-extra": "^11.0.4", diff --git a/packages/create-waku/index.ts b/packages/create-waku/src/cli.ts similarity index 100% rename from packages/create-waku/index.ts rename to packages/create-waku/src/cli.ts diff --git a/packages/create-waku/tsconfig.json b/packages/create-waku/tsconfig.json index 113d1fe12..42a2ce85a 100644 --- a/packages/create-waku/tsconfig.json +++ b/packages/create-waku/tsconfig.json @@ -1,12 +1,12 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": ".", + "rootDir": "./src", "outDir": "./dist", "lib": ["esnext"], "emitDeclarationOnly": false }, - "include": ["./index.ts"], + "include": ["./src"], "exclude": ["./template"], "references": [ { From e77ef31b399b7464d33a82cb9b221c7ef0a9d91a Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Thu, 28 Dec 2023 17:59:36 -0600 Subject: [PATCH 13/17] fix: renaming --- packages/create-waku/package.json | 8 ++++---- packages/create-waku/src/{cli.ts => index.ts} | 0 2 files changed, 4 insertions(+), 4 deletions(-) rename packages/create-waku/src/{cli.ts => index.ts} (100%) diff --git a/packages/create-waku/package.json b/packages/create-waku/package.json index daa5db42e..3fc40bd12 100644 --- a/packages/create-waku/package.json +++ b/packages/create-waku/package.json @@ -12,18 +12,18 @@ "directory": "packages/create-waku" }, "bin": { - "create-waku": "./dist/cli.js" + "create-waku": "./dist/index.js" }, "files": [ "dist", "template" ], "scripts": { - "start": "node ./dist/cli.js", - "dev": "ncc build ./src/cli.ts -w -o ./dist/", + "start": "node ./dist/index.js", + "dev": "ncc build ./src/index.ts -w -o ./dist/", "compile": "rm -rf template dist *.tsbuildinfo && pnpm run template && pnpm run build", "template": "cp -r ../../examples template/ && rm -rf template/*/dist && rm -rf template/*/node_modules", - "build": "ncc build ./src/cli.ts -o ./dist/ --minify --no-cache --no-source-map-register" + "build": "ncc build ./src/index.ts -o ./dist/ --minify --no-cache --no-source-map-register" }, "devDependencies": { "@types/fs-extra": "^11.0.4", diff --git a/packages/create-waku/src/cli.ts b/packages/create-waku/src/index.ts similarity index 100% rename from packages/create-waku/src/cli.ts rename to packages/create-waku/src/index.ts From 43bb72122cb31d807fd0254444fe8eef8e20260f Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Thu, 28 Dec 2023 23:37:25 -0600 Subject: [PATCH 14/17] Update index.ts Co-authored-by: Daishi Kato --- packages/create-waku/src/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/create-waku/src/index.ts b/packages/create-waku/src/index.ts index 9d75aa8aa..be815f6aa 100644 --- a/packages/create-waku/src/index.ts +++ b/packages/create-waku/src/index.ts @@ -30,8 +30,7 @@ function canSafelyOverwrite(dir: string) { async function init() { let targetDir = ''; const defaultProjectName = 'waku-project'; - const __dirname = dirname(fileURLToPath(import.meta.url)); - const templateRoot = path.resolve(__dirname, '../template'); + const templateRoot = path.join(fileURLToPath(import.meta.url), '../../template'); // maybe include `.DS_Store` on macOS const CHOICES = (await fsPromises.readdir(templateRoot)).filter( (dir) => !dir.startsWith('.'), From e6103eb1f8a1c82a83f1dd216afd10d2ae688526 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Fri, 29 Dec 2023 00:47:21 -0600 Subject: [PATCH 15/17] fix: import --- packages/create-waku/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-waku/src/index.ts b/packages/create-waku/src/index.ts index be815f6aa..86162eca0 100644 --- a/packages/create-waku/src/index.ts +++ b/packages/create-waku/src/index.ts @@ -1,7 +1,7 @@ #!/usr/bin/env node import { existsSync, readdirSync } from 'node:fs'; import fsPromises from 'node:fs/promises'; -import path, { dirname } from 'node:path'; +import path from 'node:path'; import { default as prompts } from 'prompts'; import { red, green, bold } from 'kolorist'; import fse from 'fs-extra/esm'; From 4e668b875707295ad1f9e41a273f38ec58cce5b3 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Fri, 29 Dec 2023 00:47:53 -0600 Subject: [PATCH 16/17] fix: import --- packages/create-waku/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-waku/src/index.ts b/packages/create-waku/src/index.ts index 86162eca0..666843050 100644 --- a/packages/create-waku/src/index.ts +++ b/packages/create-waku/src/index.ts @@ -2,10 +2,10 @@ import { existsSync, readdirSync } from 'node:fs'; import fsPromises from 'node:fs/promises'; import path from 'node:path'; +import { fileURLToPath } from 'node:url'; import { default as prompts } from 'prompts'; import { red, green, bold } from 'kolorist'; import fse from 'fs-extra/esm'; -import { fileURLToPath } from 'node:url'; function isValidPackageName(projectName: string) { return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test( From 46768317e56a91fad68132781ca328a70e80cbdc Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Fri, 29 Dec 2023 01:26:13 -0600 Subject: [PATCH 17/17] fix: lint --- packages/create-waku/src/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/create-waku/src/index.ts b/packages/create-waku/src/index.ts index 666843050..d320e03fe 100644 --- a/packages/create-waku/src/index.ts +++ b/packages/create-waku/src/index.ts @@ -30,7 +30,10 @@ function canSafelyOverwrite(dir: string) { async function init() { let targetDir = ''; const defaultProjectName = 'waku-project'; - const templateRoot = path.join(fileURLToPath(import.meta.url), '../../template'); + const templateRoot = path.join( + fileURLToPath(import.meta.url), + '../../template', + ); // maybe include `.DS_Store` on macOS const CHOICES = (await fsPromises.readdir(templateRoot)).filter( (dir) => !dir.startsWith('.'),