From e97df6e716e23a7c707e63b0ba36c2888a9bcea6 Mon Sep 17 00:00:00 2001 From: David Herman Date: Fri, 15 Nov 2024 12:57:46 -0800 Subject: [PATCH 01/10] Add support for namespaced (and optionally prefixed) NPM binary packages. Details: - optionally generate prefix field when generating package.json - bump generated CLI dependency number to 0.1.82 - allow both `quux` and `@foobar/quux` style names in cmdline arg - allow naming scheme to be given explicitly via `--cache npm[:org[/prefix]]` --- .../templates/manifest/base/library.json.hbs | 3 ++ pkgs/create-neon/data/versions.json | 4 +- pkgs/create-neon/src/bin/create-neon.ts | 50 +++++++++++++++---- pkgs/create-neon/src/cache/npm.ts | 11 ++-- pkgs/create-neon/src/create/creator.ts | 1 + 5 files changed, 51 insertions(+), 18 deletions(-) diff --git a/pkgs/create-neon/data/templates/manifest/base/library.json.hbs b/pkgs/create-neon/data/templates/manifest/base/library.json.hbs index 361d581e3..9b0068f6f 100644 --- a/pkgs/create-neon/data/templates/manifest/base/library.json.hbs +++ b/pkgs/create-neon/data/templates/manifest/base/library.json.hbs @@ -28,6 +28,9 @@ {{#if options.library.cache.org}} "org": "{{options.library.cache.org}}", {{/if}} +{{#if options.library.cache.prefix}} + "prefix": "{{options.library.cache.prefix}}", +{{/if}} {{/eq}} "platforms": {}, "load": "./src/load.cts" diff --git a/pkgs/create-neon/data/versions.json b/pkgs/create-neon/data/versions.json index 46f2b4999..6bc63a0a1 100644 --- a/pkgs/create-neon/data/versions.json +++ b/pkgs/create-neon/data/versions.json @@ -1,7 +1,7 @@ { "neon": "1", - "neonCLI": "0.1.73", - "neonLoad": "0.1.73", + "neonCLI": "0.1.82", + "neonLoad": "0.1.82", "typescript": "5.3.3", "typesNode": "20.11.16", "tsconfigNode": { diff --git a/pkgs/create-neon/src/bin/create-neon.ts b/pkgs/create-neon/src/bin/create-neon.ts index caec20f2e..2d269aa6a 100644 --- a/pkgs/create-neon/src/bin/create-neon.ts +++ b/pkgs/create-neon/src/bin/create-neon.ts @@ -40,8 +40,10 @@ try { } const [pkg] = opts._unknown; + const { org, name } = + /^(@(?[^/]+)\/)?(?.*)/.exec(pkg)?.groups as { org: string; name: string }; const platforms = parsePlatforms(opts.platform); - const cache = parseCache(opts.lib, opts.bins, pkg); + const cache = parseCache(opts.lib, opts.bins, name, org); const ci = parseCI(opts.ci); if (opts.yes) { @@ -49,7 +51,8 @@ try { } createNeon({ - name: pkg, + org, + name, version: "0.1.0", library: opts.lib ? { @@ -112,21 +115,50 @@ function parseCI(ci: string): CI | undefined { function parseCache( lib: boolean, bins: string, - pkg: string + pkg: string, + org: string | undefined ): Cache | undefined { - if (bins === "none") { - return lib ? new NPM(pkg) : undefined; + let prefix = org ? `${pkg}-` : ""; + org ??= `@${pkg}`; + + // CASE: npm create neon -- --app logos-r-us + // CASE: npm create neon -- --app @acme/logos-r-us + // - + if (bins === "none" && !lib) { + return undefined; } - if (bins === "npm") { - return new NPM(pkg); + // CASE: npm create neon -- --lib logo-generator + // CASE: npm create neon -- --lib --bins npm logo-generator + // - lib: `logo-generator` + // - bin: `@logo-generator/darwin-arm64` + + // CASE: npm create neon -- --lib @acme/logo-generator + // CASE: npm create neon -- --lib --bins npm @acme/logo-generator + // - lib: `@acme/logo-generator` + // - bin: `@acme/logo-generator-darwin-arm64` + if (bins === "none" || bins === "npm") { + return new NPM(org, prefix); } + // CASE: npm create neon -- --lib --bins=npm:acme logo-generator + // lib: logo-generator + // bin: @acme/logo-generator-darwin-arm64 + + // CASE: npm create neon -- --lib --bins=npm:acme/libs-logo-generator- logo-generator + // lib: logo-generator + // bin: @acme/libs-logo-generator-darwin-arm64 + + // CASE: npm create neon -- --lib --bins=npm:acme-libs @acme/logo-generator + // lib: @acme-libs/logo-generator + // bin: @acme-libs/logo-generator-darwin-arm64 if (bins.startsWith("npm:")) { - return new NPM(pkg, bins.substring(4)); + const split = bins.substring(4).split('/', 2); + + return new NPM(split[0], split.length > 1 ? split[1] : prefix); } throw new Error( - `Unrecognized binaries cache ${bins}, expected 'npm[:org]' or 'none'` + `Unrecognized binaries cache ${bins}, expected 'npm[:org[/prefix]]' or 'none'` ); } diff --git a/pkgs/create-neon/src/cache/npm.ts b/pkgs/create-neon/src/cache/npm.ts index 4417c096d..894f680e7 100644 --- a/pkgs/create-neon/src/cache/npm.ts +++ b/pkgs/create-neon/src/cache/npm.ts @@ -2,15 +2,12 @@ import { Cache } from "../cache.js"; export class NPM implements Cache { readonly org: string; + readonly prefix: string; readonly type: string = "npm"; - constructor(pkg: string, org?: string) { - this.org = org || NPM.inferOrg(pkg); - } - - static inferOrg(pkg: string): string { - const m = pkg.match(/^@([^/]+)\/(.*)/); - return `@${m?.[1] ?? pkg}`; + constructor(org: string, prefix: string) { + this.org = org; + this.prefix = prefix; } } diff --git a/pkgs/create-neon/src/create/creator.ts b/pkgs/create-neon/src/create/creator.ts index 3ca9d996e..fb922d7b4 100644 --- a/pkgs/create-neon/src/create/creator.ts +++ b/pkgs/create-neon/src/create/creator.ts @@ -29,6 +29,7 @@ export type LibraryOptions = { }; export type ProjectOptions = { + org?: string | undefined; name: string; version: string; library: LibraryOptions | null; From b73e862358d4b0f3373af745378b3e63967c831f Mon Sep 17 00:00:00 2001 From: David Herman Date: Fri, 15 Nov 2024 13:11:58 -0800 Subject: [PATCH 02/10] prettier --- pkgs/create-neon/src/bin/create-neon.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/create-neon/src/bin/create-neon.ts b/pkgs/create-neon/src/bin/create-neon.ts index 2d269aa6a..1732c4118 100644 --- a/pkgs/create-neon/src/bin/create-neon.ts +++ b/pkgs/create-neon/src/bin/create-neon.ts @@ -40,8 +40,10 @@ try { } const [pkg] = opts._unknown; - const { org, name } = - /^(@(?[^/]+)\/)?(?.*)/.exec(pkg)?.groups as { org: string; name: string }; + const { org, name } = /^(@(?[^/]+)\/)?(?.*)/.exec(pkg)?.groups as { + org: string; + name: string; + }; const platforms = parsePlatforms(opts.platform); const cache = parseCache(opts.lib, opts.bins, name, org); const ci = parseCI(opts.ci); @@ -153,7 +155,7 @@ function parseCache( // lib: @acme-libs/logo-generator // bin: @acme-libs/logo-generator-darwin-arm64 if (bins.startsWith("npm:")) { - const split = bins.substring(4).split('/', 2); + const split = bins.substring(4).split("/", 2); return new NPM(split[0], split.length > 1 ? split[1] : prefix); } From 34e7bbd8f9952363d31f8f3289ad8982ad84a68d Mon Sep 17 00:00:00 2001 From: David Herman Date: Fri, 15 Nov 2024 15:52:39 -0800 Subject: [PATCH 03/10] bugfix: askProjectType needs to create an NPM cache correctly --- pkgs/create-neon/src/index.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pkgs/create-neon/src/index.ts b/pkgs/create-neon/src/index.ts index 941d34b2a..788317407 100644 --- a/pkgs/create-neon/src/index.ts +++ b/pkgs/create-neon/src/index.ts @@ -61,10 +61,21 @@ async function askProjectType(options: ProjectOptions) { ? await dialog.ask({ prompt: "cache org", parse: (v: string): string => v, - default: NPM.inferOrg(options.name), + default: `@${options.org ?? options.name}`, }) : null; + const prefix = + cache === "npm" && org === `@${options.name}` + ? "" + : cache === "npm" + ? await dialog.ask({ + prompt: "cache prefix", + parse: (v: string): string => v, + default: `${options.name}-`, + }) + : null; + const ci = await dialog.ask({ prompt: "ci provider", parse: oneOf({ npm: "github" as const, none: undefined }), @@ -76,7 +87,7 @@ async function askProjectType(options: ProjectOptions) { options.library = { lang: Lang.TS, module: ModuleType.ESM, - cache: cache === "npm" ? new NPM(options.name, org!) : undefined, + cache: cache === "npm" ? new NPM(org!, prefix!) : undefined, ci: ci === "github" ? new GitHub() : undefined, platforms: platforms.length === 1 ? platforms[0] : platforms, }; From 8fef4fdec9e749bea0e041602f6e3da166b79adc Mon Sep 17 00:00:00 2001 From: David Herman Date: Fri, 15 Nov 2024 15:58:33 -0800 Subject: [PATCH 04/10] prettier --- pkgs/create-neon/src/index.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/create-neon/src/index.ts b/pkgs/create-neon/src/index.ts index 788317407..fdf9eb03e 100644 --- a/pkgs/create-neon/src/index.ts +++ b/pkgs/create-neon/src/index.ts @@ -67,14 +67,14 @@ async function askProjectType(options: ProjectOptions) { const prefix = cache === "npm" && org === `@${options.name}` - ? "" - : cache === "npm" - ? await dialog.ask({ - prompt: "cache prefix", - parse: (v: string): string => v, - default: `${options.name}-`, - }) - : null; + ? "" + : cache === "npm" + ? await dialog.ask({ + prompt: "cache prefix", + parse: (v: string): string => v, + default: `${options.name}-`, + }) + : null; const ci = await dialog.ask({ prompt: "ci provider", From 4dff419c1eba6dc891908022dabbb8e2c0dbdf51 Mon Sep 17 00:00:00 2001 From: David Herman Date: Sat, 16 Nov 2024 00:00:29 -0800 Subject: [PATCH 05/10] squashing bugs: more clearly distinguish between when we're asking for the org, when we're asking for the base name of the package, and when we're asking for the fully qualified package name also, bump the manifest version in create-neon so it recognizes prefixes --- package-lock.json | 8 ++++---- .../templates/manifest/base/default.json.hbs | 2 +- .../templates/manifest/base/library.json.hbs | 2 +- pkgs/create-neon/package.json | 2 +- pkgs/create-neon/src/bin/create-neon.ts | 19 +++++++++++-------- pkgs/create-neon/src/create/creator.ts | 11 ++++++----- pkgs/create-neon/src/index.ts | 16 ++++++++-------- 7 files changed, 32 insertions(+), 28 deletions(-) diff --git a/package-lock.json b/package-lock.json index 59bd7ae2f..97c4532b5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -833,9 +833,9 @@ } }, "node_modules/@neon-rs/manifest": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@neon-rs/manifest/-/manifest-0.1.0.tgz", - "integrity": "sha512-CtmcJbqczgEjiU169n+ZdmWwKLDFz5PSybmD6JbzzzWIi9JaLh5Jpk67vipN5AnEwYUEtXVSUmmkJGwzRBu5Ug==", + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@neon-rs/manifest/-/manifest-0.2.1.tgz", + "integrity": "sha512-DDDROadZXorclce/M/pHTmgwllgSt6Dm7KFhiGPP+pThYgg6K4igspha93UQyxmq6Y12yvrQlcEjK6TPaamlZQ==", "dependencies": { "jscodeshift": "^0.15.1" } @@ -6069,7 +6069,7 @@ "version": "0.5.2", "license": "MIT", "dependencies": { - "@neon-rs/manifest": "^0.1.0", + "@neon-rs/manifest": "^0.2.1", "chalk": "^5.3.0", "command-line-args": "^5.2.1", "command-line-usage": "^7.0.1", diff --git a/pkgs/create-neon/data/templates/manifest/base/default.json.hbs b/pkgs/create-neon/data/templates/manifest/base/default.json.hbs index 2d02d4e29..653552207 100644 --- a/pkgs/create-neon/data/templates/manifest/base/default.json.hbs +++ b/pkgs/create-neon/data/templates/manifest/base/default.json.hbs @@ -1,6 +1,6 @@ { - "name": "{{options.name}}", + "name": "{{options.fullName}}", "version": "{{options.version}}", "main": "index.node", "scripts": {}, diff --git a/pkgs/create-neon/data/templates/manifest/base/library.json.hbs b/pkgs/create-neon/data/templates/manifest/base/library.json.hbs index 9b0068f6f..647f47db7 100644 --- a/pkgs/create-neon/data/templates/manifest/base/library.json.hbs +++ b/pkgs/create-neon/data/templates/manifest/base/library.json.hbs @@ -1,6 +1,6 @@ { - "name": "{{options.name}}", + "name": "{{options.fullName}}", "version": "{{options.version}}", {{#eq options.library.module compare="esm"}} "exports": { diff --git a/pkgs/create-neon/package.json b/pkgs/create-neon/package.json index 6b2796e7e..abe8985a4 100644 --- a/pkgs/create-neon/package.json +++ b/pkgs/create-neon/package.json @@ -48,7 +48,7 @@ "typescript": "^5.3.2" }, "dependencies": { - "@neon-rs/manifest": "^0.1.0", + "@neon-rs/manifest": "^0.2.1", "chalk": "^5.3.0", "command-line-args": "^5.2.1", "command-line-usage": "^7.0.1", diff --git a/pkgs/create-neon/src/bin/create-neon.ts b/pkgs/create-neon/src/bin/create-neon.ts index 1732c4118..e22ff574b 100644 --- a/pkgs/create-neon/src/bin/create-neon.ts +++ b/pkgs/create-neon/src/bin/create-neon.ts @@ -40,12 +40,13 @@ try { } const [pkg] = opts._unknown; - const { org, name } = /^(@(?[^/]+)\/)?(?.*)/.exec(pkg)?.groups as { + const { org, basename } = /^((?@[^/]+)\/)?(?.*)/.exec(pkg)?.groups as { org: string; - name: string; + basename: string; }; + const fullName = org ? `${org}/${basename}` : basename; const platforms = parsePlatforms(opts.platform); - const cache = parseCache(opts.lib, opts.bins, name, org); + const cache = parseCache(opts.lib, opts.bins, basename, org); const ci = parseCI(opts.ci); if (opts.yes) { @@ -54,7 +55,8 @@ try { createNeon({ org, - name, + basename, + fullName, version: "0.1.0", library: opts.lib ? { @@ -120,7 +122,7 @@ function parseCache( pkg: string, org: string | undefined ): Cache | undefined { - let prefix = org ? `${pkg}-` : ""; + const defaultPrefix = org ? `${pkg}-` : ""; org ??= `@${pkg}`; // CASE: npm create neon -- --app logos-r-us @@ -140,7 +142,7 @@ function parseCache( // - lib: `@acme/logo-generator` // - bin: `@acme/logo-generator-darwin-arm64` if (bins === "none" || bins === "npm") { - return new NPM(org, prefix); + return new NPM(org, defaultPrefix); } // CASE: npm create neon -- --lib --bins=npm:acme logo-generator @@ -156,8 +158,9 @@ function parseCache( // bin: @acme-libs/logo-generator-darwin-arm64 if (bins.startsWith("npm:")) { const split = bins.substring(4).split("/", 2); - - return new NPM(split[0], split.length > 1 ? split[1] : prefix); + const org = split[0].replace(/^@?/, '@'); // don't care if they include the @ or not + const prefix = split.length > 1 ? split[1] : defaultPrefix; + return new NPM(org, prefix); } throw new Error( diff --git a/pkgs/create-neon/src/create/creator.ts b/pkgs/create-neon/src/create/creator.ts index fb922d7b4..302ed8bca 100644 --- a/pkgs/create-neon/src/create/creator.ts +++ b/pkgs/create-neon/src/create/creator.ts @@ -30,7 +30,8 @@ export type LibraryOptions = { export type ProjectOptions = { org?: string | undefined; - name: string; + basename: string; + fullName: string; version: string; library: LibraryOptions | null; app: boolean | null; @@ -65,12 +66,12 @@ export abstract class Creator { async create(cx: Context): Promise { try { this._temp = await mktemp(); - this._tempPkg = path.join(this._temp, this._options.name); + this._tempPkg = path.join(this._temp, this._options.basename); await fs.mkdir(this._tempPkg); } catch (err: any) { await die( - `Could not create \`${this._options.name}\`: ${err.message}`, + `Could not create \`${this._options.basename}\`: ${err.message}`, this._temp ); } @@ -123,11 +124,11 @@ export abstract class Creator { await this.createNeonBoilerplate(cx); try { - await fs.rename(this._tempPkg, this._options.name); + await fs.rename(this._tempPkg, this._options.basename); await fs.rmdir(this._temp); } catch (err: any) { await die( - `Could not create \`${this._options.name}\`: ${err.message}`, + `Could not create \`${this._options.basename}\`: ${err.message}`, this._tempPkg ); } diff --git a/pkgs/create-neon/src/index.ts b/pkgs/create-neon/src/index.ts index fdf9eb03e..711aba96e 100644 --- a/pkgs/create-neon/src/index.ts +++ b/pkgs/create-neon/src/index.ts @@ -58,21 +58,21 @@ async function askProjectType(options: ProjectOptions) { const org = cache === "npm" - ? await dialog.ask({ + ? (await dialog.ask({ prompt: "cache org", parse: (v: string): string => v, - default: `@${options.org ?? options.name}`, - }) + default: `@${options.org ?? options.basename}`, + })).replace(/^@?/, "@") // don't care if they include the @ or not : null; const prefix = - cache === "npm" && org === `@${options.name}` + cache === "npm" && org === `@${options.basename}` ? "" : cache === "npm" ? await dialog.ask({ prompt: "cache prefix", parse: (v: string): string => v, - default: `${options.name}-`, + default: `${options.basename}-`, }) : null; @@ -99,9 +99,9 @@ async function askProjectType(options: ProjectOptions) { export async function createNeon(options: ProjectOptions): Promise { try { - await assertCanMkdir(options.name); + await assertCanMkdir(options.basename); } catch (err: any) { - await die(`Could not create \`${options.name}\`: ${err.message}`); + await die(`Could not create \`${options.basename}\`: ${err.message}`); } const cx = new Context(options); @@ -124,6 +124,6 @@ export async function createNeon(options: ProjectOptions): Promise { await creator.create(cx); console.log( - `✨ Created Neon project \`${options.name}\`. Happy 🦀 hacking! ✨` + `✨ Created Neon project \`${options.fullName}\`. Happy 🦀 hacking! ✨` ); } From 8a560ffea5b96c6d694eb05f153bd56f87327742 Mon Sep 17 00:00:00 2001 From: David Herman Date: Sat, 16 Nov 2024 00:02:06 -0800 Subject: [PATCH 06/10] prettier --- pkgs/create-neon/src/bin/create-neon.ts | 5 +++-- pkgs/create-neon/src/index.ts | 12 +++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pkgs/create-neon/src/bin/create-neon.ts b/pkgs/create-neon/src/bin/create-neon.ts index e22ff574b..a3a85a0f8 100644 --- a/pkgs/create-neon/src/bin/create-neon.ts +++ b/pkgs/create-neon/src/bin/create-neon.ts @@ -40,7 +40,8 @@ try { } const [pkg] = opts._unknown; - const { org, basename } = /^((?@[^/]+)\/)?(?.*)/.exec(pkg)?.groups as { + const { org, basename } = /^((?@[^/]+)\/)?(?.*)/.exec(pkg) + ?.groups as { org: string; basename: string; }; @@ -158,7 +159,7 @@ function parseCache( // bin: @acme-libs/logo-generator-darwin-arm64 if (bins.startsWith("npm:")) { const split = bins.substring(4).split("/", 2); - const org = split[0].replace(/^@?/, '@'); // don't care if they include the @ or not + const org = split[0].replace(/^@?/, "@"); // don't care if they include the @ or not const prefix = split.length > 1 ? split[1] : defaultPrefix; return new NPM(org, prefix); } diff --git a/pkgs/create-neon/src/index.ts b/pkgs/create-neon/src/index.ts index 711aba96e..57eec7847 100644 --- a/pkgs/create-neon/src/index.ts +++ b/pkgs/create-neon/src/index.ts @@ -58,11 +58,13 @@ async function askProjectType(options: ProjectOptions) { const org = cache === "npm" - ? (await dialog.ask({ - prompt: "cache org", - parse: (v: string): string => v, - default: `@${options.org ?? options.basename}`, - })).replace(/^@?/, "@") // don't care if they include the @ or not + ? ( + await dialog.ask({ + prompt: "cache org", + parse: (v: string): string => v, + default: `@${options.org ?? options.basename}`, + }) + ).replace(/^@?/, "@") // don't care if they include the @ or not : null; const prefix = From 1f4836c3ba2cbdd135081913e393fcdf70842804 Mon Sep 17 00:00:00 2001 From: David Herman Date: Sat, 16 Nov 2024 11:59:24 -0800 Subject: [PATCH 07/10] - bump create-neon version to 0.6.0 (since the public API technically changed) - bugfix: fix double-@ in interactive dialog - tests: add test of interactive dialog when package is namespaced --- pkgs/create-neon/package.json | 2 +- pkgs/create-neon/src/index.ts | 2 +- pkgs/create-neon/test/create-neon.ts | 41 ++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/pkgs/create-neon/package.json b/pkgs/create-neon/package.json index abe8985a4..cbc2dc9e0 100644 --- a/pkgs/create-neon/package.json +++ b/pkgs/create-neon/package.json @@ -1,6 +1,6 @@ { "name": "create-neon", - "version": "0.5.2", + "version": "0.6.0", "description": "Create Neon projects with no build configuration.", "type": "module", "exports": "./dist/src/bin/create-neon.js", diff --git a/pkgs/create-neon/src/index.ts b/pkgs/create-neon/src/index.ts index 57eec7847..2fee357c2 100644 --- a/pkgs/create-neon/src/index.ts +++ b/pkgs/create-neon/src/index.ts @@ -62,7 +62,7 @@ async function askProjectType(options: ProjectOptions) { await dialog.ask({ prompt: "cache org", parse: (v: string): string => v, - default: `@${options.org ?? options.basename}`, + default: options.org ?? `@${options.basename}`, }) ).replace(/^@?/, "@") // don't care if they include the @ or not : null; diff --git a/pkgs/create-neon/test/create-neon.ts b/pkgs/create-neon/test/create-neon.ts index ef747b25c..c85456095 100644 --- a/pkgs/create-neon/test/create-neon.ts +++ b/pkgs/create-neon/test/create-neon.ts @@ -33,6 +33,7 @@ describe("Command-line argument validation", () => { }); const PROJECT = "create-neon-test-project"; +const NAMESPACED_PROJECT = "@dherman/create-neon-test-project"; describe("Project creation", () => { afterEach(async () => { @@ -182,6 +183,46 @@ describe("Project creation", () => { assert.strictEqual(json.neon.type, "library"); assert.strictEqual(json.neon.org, "@create-neon-test-project"); + assert.notProperty(json.neon, "prefix"); + assert.strictEqual(json.neon.platforms, "common"); + assert.strictEqual(json.neon.load, "./src/load.cts"); + + TOML.parse( + await fs.readFile(path.join(PROJECT, "Cargo.toml"), { encoding: "utf8" }) + ); + }); + + it("asks for a prefix when Neon lib is namespaced", async () => { + try { + await expect(spawn(NODE, [CREATE_NEON, NAMESPACED_PROJECT]), { + "neon project type": "lib", + "neon target platforms": "", + "neon binary cache": "", + "neon cache org": "", + "neon cache prefix": "", + "neon ci provider": "", + "package name:": "", + "version:": "", + "description:": "", + "git repository:": "", + "keywords:": "", + "author:": "", + "license:": "", + "Is this OK?": "", + }); + } catch (error: any) { + assert.fail("create-neon unexpectedly failed: " + error.message); + } + + let json = JSON.parse( + await fs.readFile(path.join(PROJECT, "package.json"), { + encoding: "utf8", + }) + ); + + assert.strictEqual(json.neon.type, "library"); + assert.strictEqual(json.neon.org, "@dherman"); + assert.strictEqual(json.neon.prefix, "create-neon-test-project-") assert.strictEqual(json.neon.platforms, "common"); assert.strictEqual(json.neon.load, "./src/load.cts"); From 24534d91fa53fb1a5a64158269232186086996c3 Mon Sep 17 00:00:00 2001 From: David Herman Date: Sat, 16 Nov 2024 12:00:52 -0800 Subject: [PATCH 08/10] prettier --- pkgs/create-neon/test/create-neon.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/create-neon/test/create-neon.ts b/pkgs/create-neon/test/create-neon.ts index c85456095..f8c0d3f6d 100644 --- a/pkgs/create-neon/test/create-neon.ts +++ b/pkgs/create-neon/test/create-neon.ts @@ -222,7 +222,7 @@ describe("Project creation", () => { assert.strictEqual(json.neon.type, "library"); assert.strictEqual(json.neon.org, "@dherman"); - assert.strictEqual(json.neon.prefix, "create-neon-test-project-") + assert.strictEqual(json.neon.prefix, "create-neon-test-project-"); assert.strictEqual(json.neon.platforms, "common"); assert.strictEqual(json.neon.load, "./src/load.cts"); From aa7441e0d2efaf5e05f2f3517e2462b770b1494c Mon Sep 17 00:00:00 2001 From: Dave Herman Date: Tue, 19 Nov 2024 16:49:27 -0800 Subject: [PATCH 09/10] nit: mark `org` field as optional in typecast Co-authored-by: K.J. Valencik --- pkgs/create-neon/src/bin/create-neon.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/create-neon/src/bin/create-neon.ts b/pkgs/create-neon/src/bin/create-neon.ts index a3a85a0f8..07e9397cb 100644 --- a/pkgs/create-neon/src/bin/create-neon.ts +++ b/pkgs/create-neon/src/bin/create-neon.ts @@ -42,7 +42,7 @@ try { const [pkg] = opts._unknown; const { org, basename } = /^((?@[^/]+)\/)?(?.*)/.exec(pkg) ?.groups as { - org: string; + org?: string; basename: string; }; const fullName = org ? `${org}/${basename}` : basename; From ac53ea156770f8b5189a11f5ca1c95a8ff201f9b Mon Sep 17 00:00:00 2001 From: David Herman Date: Tue, 19 Nov 2024 16:50:46 -0800 Subject: [PATCH 10/10] good catch by @kjvalencik -- don't recreate `pkg`, it's already there --- pkgs/create-neon/src/bin/create-neon.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/create-neon/src/bin/create-neon.ts b/pkgs/create-neon/src/bin/create-neon.ts index 07e9397cb..ae435ff40 100644 --- a/pkgs/create-neon/src/bin/create-neon.ts +++ b/pkgs/create-neon/src/bin/create-neon.ts @@ -45,7 +45,7 @@ try { org?: string; basename: string; }; - const fullName = org ? `${org}/${basename}` : basename; + const fullName = org ? pkg : basename; const platforms = parsePlatforms(opts.platform); const cache = parseCache(opts.lib, opts.bins, basename, org); const ci = parseCI(opts.ci);