@_linked/cli 1.44.1 → 1.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +36 -2
  3. package/defaults/package/src/index.ts +0 -5
  4. package/defaults/package-ontology/src/index.ts +8 -0
  5. package/defaults/shape.ts +13 -10
  6. package/lib/esm/cli-methods.d.ts +10 -1
  7. package/lib/esm/cli-methods.d.ts.map +1 -1
  8. package/lib/esm/cli-methods.js +252 -97
  9. package/lib/esm/cli-methods.js.map +1 -1
  10. package/lib/esm/cli.js +60 -17
  11. package/lib/esm/cli.js.map +1 -1
  12. package/lib/esm/localize/localize.d.ts.map +1 -1
  13. package/lib/esm/localize/localize.js +25 -3
  14. package/lib/esm/localize/localize.js.map +1 -1
  15. package/lib/esm/utils/createPackageLocation.d.ts +20 -5
  16. package/lib/esm/utils/createPackageLocation.d.ts.map +1 -1
  17. package/lib/esm/utils/createPackageLocation.js +9 -14
  18. package/lib/esm/utils/createPackageLocation.js.map +1 -1
  19. package/lib/esm/utils/packageBaseUri.d.ts +27 -0
  20. package/lib/esm/utils/packageBaseUri.d.ts.map +1 -0
  21. package/lib/esm/utils/packageBaseUri.js +91 -0
  22. package/lib/esm/utils/packageBaseUri.js.map +1 -0
  23. package/lib/esm/utils/packageKind.d.ts +49 -0
  24. package/lib/esm/utils/packageKind.d.ts.map +1 -0
  25. package/lib/esm/utils/packageKind.js +94 -0
  26. package/lib/esm/utils/packageKind.js.map +1 -0
  27. package/lib/esm/utils/relinkHooks.d.ts +19 -0
  28. package/lib/esm/utils/relinkHooks.d.ts.map +1 -0
  29. package/lib/esm/utils/relinkHooks.js +74 -0
  30. package/lib/esm/utils/relinkHooks.js.map +1 -0
  31. package/package.json +1 -1
  32. /package/defaults/{package → package-ontology}/src/data/example-ontology.json +0 -0
  33. /package/defaults/{package → package-ontology}/src/data/example-ontology.json.d.ts +0 -0
  34. /package/defaults/{package → package-ontology}/src/ontologies/example-ontology.register.ts +0 -0
  35. /package/defaults/{package → package-ontology}/src/ontologies/example-ontology.ts +0 -0
package/lib/esm/cli.js CHANGED
@@ -94,25 +94,68 @@ program
94
94
  .option('--env', 'The node environment to use. Default is "development"')
95
95
  .description('Start the Linked node.js server but without http server. Instead it immediately runs the specified script and exits afterwards')
96
96
  .argument('<scriptName>', 'the name of the script file inside the /scripts folder');
97
- program
97
+ /** A refusal of the create-* commands exits 1 with the message, not a stack. */
98
+ const reportRefusal = (e) => {
99
+ if (!(e instanceof CreatePackageError))
100
+ throw e;
101
+ console.error(chalk.red(e.message));
102
+ process.exitCode = 1;
103
+ };
104
+ const LOCATION_HELP = "packages: part of this app's repository, a workspace member added to its dependencies. packages-local: its own git repository (git init + a first commit), linked and recorded by `linked localize` and not added to the app's dependencies until it is published.";
105
+ const REMOTE_HELP = "The new repository's origin; also written to repository.url. Implies --location packages-local.";
106
+ const PUSH_HELP = 'Push the first commit to --remote.';
107
+ const SKIP_INSTALL_HELP = 'Write the files only: no install, no build, no git.';
108
+ const BASE_URI_HELP = "The root the package's IRIs are minted under: linkedPackage(name, {baseUri}), shapes at <uri>shape/<package>/<Name>, ontology terms at <uri>ont/<slug>/<Term>. Inside an app it defaults to LINKED_BASE_URI from the environment, then the app's .env.local, then its .env; with none of them the package declares no root and falls back to https://linked.cm/.";
109
+ const WHERE_HELP = "Inside an app, it goes in packages/ (part of the app's repository) or packages-local/ (its own git repository, linked with `linked localize`); without --location, --remote or --push you are asked, on a terminal.";
110
+ /** The three scaffolding commands share the where-flags; `--kind` is create-package's own. */
111
+ const withPackageOptions = (command) => command
112
+ .option('--location <where>', LOCATION_HELP)
113
+ .option('--remote <git-url>', REMOTE_HELP)
114
+ .option('--push', PUSH_HELP)
115
+ .option('--skip-install', SKIP_INSTALL_HELP)
116
+ .option('--base-uri <uri>', BASE_URI_HELP);
117
+ withPackageOptions(program
98
118
  .command('create-package')
99
119
  .action((name, uriBase, options) => __awaiter(void 0, void 0, void 0, function* () {
100
120
  try {
101
121
  yield createPackage(name, uriBase, process.cwd(), options);
102
122
  }
103
123
  catch (e) {
104
- if (!(e instanceof CreatePackageError))
105
- throw e;
106
- console.error(chalk.red(e.message));
107
- process.exitCode = 1;
124
+ reportRefusal(e);
125
+ }
126
+ }))
127
+ .description('Create a new Linked package: an ontology package (<name>-ont: one ontology, no shapes), an asset package (<name>-assets: shapes, components and a backend) or both. Without --kind you are asked, on a terminal. A name that already ends in -ont or -assets keeps it (foo-ont stays foo-ont). ' +
128
+ WHERE_HELP)
129
+ .option('--kind <kind>', 'ontology, assets or both. `both` creates <name>-ont and <name>-assets; it cannot take --remote (one repository cannot hold two packages).')
130
+ .argument('<name>', 'The name of the package, without the kind suffix: the package is named <name>-ont or <name>-assets (a name that already ends in the suffix is kept). An npm scope is kept (@acme/foo → @acme/foo-ont).')
131
+ .argument('[uri_base]', "The namespace of the ontology package's ontology. Leave blank for https://linked.cm/ont/<name>/ (the ontology slug is <name>, without -ont)."));
132
+ withPackageOptions(program
133
+ .command('create-ont-package')
134
+ .action((name, uriBase, options) => __awaiter(void 0, void 0, void 0, function* () {
135
+ try {
136
+ yield createPackage(name, uriBase, process.cwd(), Object.assign(Object.assign({}, options), { kind: 'ontology' }));
137
+ }
138
+ catch (e) {
139
+ reportRefusal(e);
140
+ }
141
+ }))
142
+ .description('Create an ontology package <name>-ont: exactly one ontology (src/ontologies/<name>.ts), no shapes, components or backend. Its ontology slug is <name>, so its terms mint {root}ont/<name>/{Term}. A name that already ends in -ont keeps it. ' +
143
+ WHERE_HELP)
144
+ .argument('<name>', 'The ontology slug; the package is named <name>-ont (foo-ont stays foo-ont).')
145
+ .argument('[uri_base]', 'The namespace of the ontology. Leave blank for https://linked.cm/ont/<name>/.'));
146
+ withPackageOptions(program
147
+ .command('create-asset-package')
148
+ .action((name, options) => __awaiter(void 0, void 0, void 0, function* () {
149
+ try {
150
+ yield createPackage(name, undefined, process.cwd(), Object.assign(Object.assign({}, options), { kind: 'assets' }));
151
+ }
152
+ catch (e) {
153
+ reportRefusal(e);
108
154
  }
109
155
  }))
110
- .description("Create a new folder with all the required files for a new Linked package. Inside an app, it goes in packages/ (part of the app's repository) or packages-local/ (its own git repository, linked with `linked localize`); without --location, --remote or --push you are asked, on a terminal.")
111
- .option('--location <where>', "packages: part of this app's repository, a workspace member added to its dependencies. packages-local: its own git repository (git init + a first commit), linked and recorded by `linked localize` and not added to the app's dependencies until it is published.")
112
- .option('--remote <git-url>', "The new repository's origin; also written to repository.url. Implies --location packages-local.")
113
- .option('--push', 'Push the first commit to --remote.')
114
- .argument('<name>', 'The name of the package. Will be used as package name in package.json')
115
- .argument('[uri_base]', 'The base URL used for data of this package. Leave blank to use the URL of your package on lincd.org after you register it');
156
+ .description('Create an asset package <name>-assets: shapes, components and a backend (src/shapes, src/components, src/backend.ts), and no ontology. A name that already ends in -assets keeps it. ' +
157
+ WHERE_HELP)
158
+ .argument('<name>', 'The package is named <name>-assets (foo-assets stays foo-assets).'));
116
159
  program
117
160
  .command('upgrade-packages')
118
161
  .action(() => {
@@ -122,28 +165,28 @@ program
122
165
  program
123
166
  .command('create-shape')
124
167
  .action((name, uriBase) => {
125
- return createShape(name);
168
+ return createShape(name).catch(reportRefusal);
126
169
  })
127
- .description('Creates a new ShapeClass file for your package. Execute this from your package folder.')
170
+ .description('Creates a new ShapeClass file for your package. Execute this from your package folder (packages/<name>), not the app root: an app registers no package.')
128
171
  .argument('<name>', 'The name of the shape. Will be used for the file name and the class name');
129
172
  program
130
173
  .command('create-component')
131
174
  .action((name, uriBase) => {
132
- return createComponent(name);
175
+ return createComponent(name).catch(reportRefusal);
133
176
  })
134
- .description('Creates a new Component file for your package. Execute this from your package folder.')
177
+ .description('Creates a new Component file for your package. Execute this from your package folder (packages/<name>), not the app root: an app registers no package.')
135
178
  .argument('<name>', 'The name of the component. Will be used for the file name and the export name');
136
179
  program
137
180
  .command('create-set-component')
138
181
  .action((name, uriBase) => {
139
- return createSetComponent(name);
182
+ return createSetComponent(name).catch(reportRefusal);
140
183
  })
141
184
  .description('Creates a new SetComponent file for your package. Execute this from your package folder.')
142
185
  .argument('<name>', 'The name of the component. Will be used for the file name and the export name');
143
186
  program
144
187
  .command('create-ontology')
145
188
  .action((prefix, uriBase) => {
146
- return createOntology(prefix, uriBase);
189
+ return createOntology(prefix, uriBase).catch(reportRefusal);
147
190
  })
148
191
  .description('Creates a new ontology file for your package. Execute this from your package folder.')
149
192
  .argument('<suggested-prefix>', 'The suggested prefix for your ontology. Also the shorthand code used for the file name and the exported ontology object')
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AACA,oHAAoH;AACpH,yCAAyC;;;;;;;;;;AAEzC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,SAAS,EACT,eAAe,EACf,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,QAAQ,EACR,cAAc,EACd,cAAc,EACd,4BAA4B,EAC5B,wBAAwB,EACxB,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,QAAQ,EACR,SAAS,EACT,SAAS,EAET,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,4CAA4C;AAC5C,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,kBAAkB,EAAC,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,oBAAoB,CAAC;AAC5B,OAAO,EAAC,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAE/D;;;;GAIG;AACH,MAAM,aAAa,GAAG,CAAO,GAA2B,EAAiB,EAAE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CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;IACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC","sourcesContent":["#!/usr/bin/env tsx\n//The line above calls the TSX typescript executer as runtime, which extends node.js and supports running typescript\n// see: https://www.npmjs.com/package/tsx\n\nimport chalk from 'chalk';\nimport {\n addCapacitor,\n buildAll,\n buildPackage,\n buildUpdated,\n checkImports,\n compilePackage,\n createApp,\n createComponent,\n createOntology,\n createPackage,\n createSetComponent,\n createShape,\n depCheck,\n depCheckStaged,\n developPackage,\n executeCommandForEachPackage,\n executeCommandForPackage,\n getLincdPackages,\n getScriptDir,\n publishPackage,\n publishUpdated,\n register,\n runMethod,\n runScript,\n startServer,\n upgradePackages,\n} from './cli-methods.js';\n// import {buildMetadata} from './metadata';\nimport {program} from 'commander';\nimport {CreatePackageError} from './utils/createPackageLocation.js';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport 'require-extensions';\nimport {unknownCommandError} from './unknown-command.js';\nimport {installOneCopyHook} from './localize/one-copy-hook.js';\n\n/**\n * Run an async command action and report a failure the way the rest of this\n * CLI does — one red message and exit code 1 — instead of letting the rejection\n * escape the action and print a raw unhandled-rejection stack.\n */\nconst runAppCommand = async (run: () => Promise<unknown>): Promise<void> => {\n try {\n await run();\n } catch (error) {\n const message =\n error instanceof Error ? error.message : String(error ?? 'Unknown error');\n console.error(chalk.red(message));\n if (process.env.LINKED_DEBUG && error instanceof Error && error.stack) {\n console.error(error.stack);\n }\n process.exitCode = 1;\n }\n};\n\n/** `--env a,b` → `['a', 'b']`. */\nconst splitEnvOption = (value?: string): string[] =>\n (value || '')\n .split(',')\n .map((name) => name.trim())\n .filter(Boolean);\n\nprogram\n .command('create-app')\n .action((name, options) => {\n return createApp(name, process.cwd(), {\n appName: options.appName,\n appPrefix: options.appPrefix,\n appDomain: options.appDomain,\n skipInstall: options.skipInstall,\n template: options.template,\n }).catch((err) => {\n // Report and fail the process without cutting off pending output.\n console.error(chalk.red(err?.message ?? String(err)));\n process.exitCode = 1;\n });\n })\n .description(\n 'Creates a new folder with all the required files for a Linked app',\n )\n .argument(\n '<name>',\n 'the name of your Linked app. To use spaces, wrap the name in double quotes.',\n )\n .option('--app-name <name>', 'Display name for the app (skip interactive prompt)')\n .option('--app-prefix <prefix>', 'Short code prefix for data files (skip interactive prompt)')\n .option('--app-domain <domain>', 'Domain for the app (skip interactive prompt)')\n .option('--skip-install', 'Skip running npm install after scaffolding')\n .option(\n '--template <template>',\n 'App template: \"web\" (default) or \"react-native\"',\n );\n\nprogram\n .command('start')\n .action(async (options) => {\n const {startWithVite} = await import('./commands/start.js');\n return startWithVite({env: options?.env, apiOnly: options?.apiOnly});\n })\n .option('--env <env>', 'The node environment to use. Default is \"development\"')\n .option(\n '--api-only',\n 'Serve only the backend API: no vite.config, src/App.tsx or src/routes.tsx needed; page requests get a 404',\n )\n .description(\n 'Start the Linked dev server. Vite-backed by default.',\n );\n\nprogram\n .command('call')\n .action((packageName, method, options) => {\n return runMethod(packageName, method, {spawn: options.spawn});\n })\n .option(\n '--spawn',\n 'Start a new server instance instead of using an existing one',\n )\n .option('--env', 'The node environment to use. Default is \"development\"')\n .description(\n 'Start the Linked node.js server but without http server. Instead it immediately calls the specified method of the specified package and exits afterwards',\n )\n .argument(\n '<package>',\n 'the package of the backend provider that contains this method',\n )\n .argument('<method>', 'the name of the method you want to call');\n\nprogram\n .command('script')\n .action((scriptName, options) => {\n return runScript(scriptName, {spawn: options.spawn});\n })\n .option(\n '--spawn',\n 'Start a new server instance instead of using an existing one',\n )\n .option('--env', 'The node environment to use. Default is \"development\"')\n .description(\n 'Start the Linked node.js server but without http server. Instead it immediately runs the specified script and exits afterwards',\n )\n .argument(\n '<scriptName>',\n 'the name of the script file inside the /scripts folder',\n );\n\nprogram\n .command('create-package')\n .action(async (name, uriBase, options) => {\n try {\n await createPackage(name, uriBase, process.cwd(), options);\n } catch (e) {\n if (!(e instanceof CreatePackageError)) throw e;\n console.error(chalk.red(e.message));\n process.exitCode = 1;\n }\n })\n .description(\n \"Create a new folder with all the required files for a new Linked package. Inside an app, it goes in packages/ (part of the app's repository) or packages-local/ (its own git repository, linked with `linked localize`); without --location, --remote or --push you are asked, on a terminal.\",\n )\n .option(\n '--location <where>',\n \"packages: part of this app's repository, a workspace member added to its dependencies. packages-local: its own git repository (git init + a first commit), linked and recorded by `linked localize` and not added to the app's dependencies until it is published.\",\n )\n .option(\n '--remote <git-url>',\n \"The new repository's origin; also written to repository.url. Implies --location packages-local.\",\n )\n .option('--push', 'Push the first commit to --remote.')\n .argument(\n '<name>',\n 'The name of the package. Will be used as package name in package.json',\n )\n .argument(\n '[uri_base]',\n 'The base URL used for data of this package. Leave blank to use the URL of your package on lincd.org after you register it',\n );\n\nprogram\n .command('upgrade-packages')\n .action(() => {\n return upgradePackages();\n })\n .description(\n 'Upgrade all linked packages in the workspace to ESM/CJS dual packages',\n );\n\nprogram\n .command('create-shape')\n .action((name, uriBase) => {\n return createShape(name);\n })\n .description(\n 'Creates a new ShapeClass file for your package. Execute this from your package folder.',\n )\n .argument(\n '<name>',\n 'The name of the shape. Will be used for the file name and the class name',\n );\n\nprogram\n .command('create-component')\n .action((name, uriBase) => {\n return createComponent(name);\n })\n .description(\n 'Creates a new Component file for your package. Execute this from your package folder.',\n )\n .argument(\n '<name>',\n 'The name of the component. Will be used for the file name and the export name',\n );\n\nprogram\n .command('create-set-component')\n .action((name, uriBase) => {\n return createSetComponent(name);\n })\n .description(\n 'Creates a new SetComponent file for your package. Execute this from your package folder.',\n )\n .argument(\n '<name>',\n 'The name of the component. Will be used for the file name and the export name',\n );\n\nprogram\n .command('create-ontology')\n .action((prefix, uriBase) => {\n return createOntology(prefix, uriBase);\n })\n .description(\n 'Creates a new ontology file for your package. Execute this from your package folder.',\n )\n .argument(\n '<suggested-prefix>',\n 'The suggested prefix for your ontology. Also the shorthand code used for the file name and the exported ontology object',\n )\n .argument(\n '[uribase]',\n \"Optional argument to set the URI base for the URI's of all entities in your ontology. Leave blank to use the URI's provided by lincd.org once you register this package\",\n );\n\nprogram.command('app [action]', {hidden: true}).action(() => {\n register('http://localhost:4101');\n});\nprogram.command('register-local', {hidden: true}).action(() => {\n register('http://localhost:4101');\n});\nprogram.command('register-dev', {hidden: true}).action(() => {\n register('https://dev-registry.lincd.org');\n});\nprogram\n .command('register')\n .action(() => {\n register('https://registry.lincd.org');\n })\n .description(\n 'Register (a new version of) this package to the Linked registry. If successful your package will appear on linked.cm',\n );\n\nprogram\n .command('info')\n .action(() => {\n let localDir = getScriptDir();\n let packageJsonPath = path.join(localDir, 'package.json');\n try {\n var ownPackage = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));\n } catch (e) {\n console.warn(\n 'Could not read package.json at ' + packageJsonPath + ': ' + e,\n );\n process.exit();\n }\n console.log(ownPackage.version);\n console.log('Running from: ' + localDir);\n })\n .description(\n \"Log the version of this tool and the path that it's running from\",\n );\n\nprogram\n .command('build [target] [target2]', {isDefault: true})\n .action(async (target, target2, options) => {\n const result = await buildPackage(target, target2, process.cwd(), !options?.silent);\n if (result !== true) {\n process.exitCode = 1;\n }\n })\n .option(\n '--silent',\n 'No output to console unless errors occur. The exit code is unaffected: 0 when the build succeeds (warnings included), 1 when it fails',\n );\n\nprogram\n .command('compile-only')\n .action(() => {\n compilePackage();\n })\n .description(\n 'Compile the package without other build steps. Run this command from the package folder',\n );\nprogram.command('build-metadata').action(() => {\n console.log('Needs to be reimplemented');\n // buildMetadata();\n});\nprogram\n .command('build-app')\n .action(async (options) => {\n // Vite is the only app build. An app without a `vite.config.{ts,js,mjs}`\n // is rejected by name rather than falling back to anything.\n await runAppCommand(async () => {\n const {assertViteApp, buildViteApp} = await import(\n './commands/build-app.js'\n );\n assertViteApp();\n await buildViteApp({\n environmentNames: splitEnvOption(options?.env),\n target: options?.target,\n publish: options?.publish === true,\n revision: options?.revision,\n allowDirty: options?.allowDirty === true,\n });\n });\n })\n .option('--env <env>', 'The node environment to use. Default is \"development\"')\n .option('--target <target>', 'Build target: web or capacitor')\n .option(\n '--publish',\n 'Upload the release after a successful web build (off by default; use `linked publish-app`)',\n )\n .option(\n '--revision <sha>',\n 'Revision identifying the release. Defaults to LINKED_RELEASE_REVISION, GITHUB_SHA, then git HEAD',\n )\n .option(\n '--allow-dirty',\n 'Build from a working tree with uncommitted changes; the release revision gets a \"-dirty\" suffix',\n )\n .description(\n 'Build the linked app frontend and backend for production, and write a release manifest. Requires a vite.config in the app root.',\n );\n\nprogram\n .command('publish-app')\n .option('--env <env>', 'The node environment to use')\n .option(\n '--manifest <path>',\n 'Release manifest to publish, relative to the app root. Default public/bundles/linked-release.json',\n )\n .option('--yes', 'Upload the verified release. Without it this is a dry run')\n .action(async (options) => {\n // Retry or inspect an existing release without rebuilding the app.\n await runAppCommand(async () => {\n const {ensureEnvironmentLoaded} = await import('./lifecycle.js');\n const {resolveAppAssetsStore} = await import(\n './app-release/app-assets-store.js'\n );\n const {publishApp} = await import('./commands/publish-app.js');\n await ensureEnvironmentLoaded(splitEnvOption(options?.env));\n // The store is resolved by publishApp, after the manifest is read.\n await publishApp({\n manifestPath: options?.manifest,\n resolveStore: () => resolveAppAssetsStore(),\n yes: options?.yes === true,\n });\n });\n })\n .description(\n 'Validate or retry publishing a previously built release. Defaults to dry run.',\n );\n\nprogram\n .command('serve-app')\n .option('--env <env>', 'The node environment to use')\n .action(async (options) => {\n // Production runtime loads compiled output and never starts Vite/HMR.\n await runAppCommand(async () => {\n const {serveCompiledApp} = await import('./commands/serve-app.js');\n await serveCompiledApp({environmentNames: splitEnvOption(options?.env)});\n });\n })\n .description('Start a compiled Linked app without Vite or HMR.');\n\nprogram.command('publish-updated').action(() => {\n return publishUpdated();\n});\nprogram.command('publish [version]').action((version) => {\n publishPackage(null, false, null, version);\n});\n\nprogram.command('status').action(() => {\n //log which packages need to be published\n return publishUpdated(true).then(() => {\n //log which packages need to be build\n return buildUpdated(undefined, '', '', true);\n });\n});\nprogram\n .command('build-updated [target] [target2]')\n .action((target, target2, options) => {\n const {useGit}: {useGit?: boolean} = options;\n return buildUpdated(1, target, target2, useGit || false);\n })\n .option(\n '--use-git',\n 'Use git commit timestamps to check which packages have been updated since the last build',\n );\nprogram\n .command('build-updated-since [num-commits-back] [target] [target2]')\n .action((back, target, target2) => {\n return buildUpdated(back, target, target2);\n });\nprogram\n .command('build-all')\n .action((options) => {\n buildAll(options);\n })\n .option(\n '--sync',\n 'build each package 1 by 1 - use this if you have build issues due to low available RAM memory',\n )\n .option('--from <char>', 'start from a specific package');\n\nprogram\n .command('build-workspace')\n .description(\n 'Build all linked packages in the current workspace in dependency order',\n )\n .option('-u, --updated', 'Only build updated packages')\n .option(\n '--use-git',\n 'Use git commit timestamps to determine which packages need updating',\n )\n .action(async (options) => {\n if (options.updated) {\n return buildUpdated(1, undefined, undefined, !!options.useGit);\n }\n return buildAll(options);\n });\n\nprogram\n .command('build-package <filepath>')\n .description(\n 'Given a file path, find its package.json and rebuild that package. Use for editor save hooks.',\n )\n .action(async (filepath) => {\n const {buildPackageByPath} = await import(\n './commands/build-package.js'\n );\n return buildPackageByPath(filepath);\n });\n\nprogram\n .command('localize [packages...]')\n .description(\n 'Develop an npm dependency from a git checkout: clone it, install inside the checkout, build it and symlink it into node_modules — without touching package.json or package-lock.json. Name packages exactly as npm names them (@_linked/rdfs, lodash); the repository is read from the published `repository` field. With no names, reports what is localized.',\n )\n .option('--list', 'Report what is localized rather than localizing anything.')\n .option(\n '--adopt',\n 'Link a checkout that is already in packages-local under its localize name (e.g. packages-local/_linked-foo for @_linked/foo): install, build, link and record it, without cloning or asking the registry. For a package created locally, or a clone put there by hand.',\n )\n .option(\n '--check',\n 'With --list: exit 1 when something recorded is not actually linked.',\n )\n .option(\n '--relink',\n 'Recreate the recorded symlinks. This is what a postinstall runs.',\n )\n .option(\n '--ensure',\n \"Remove every localized checkout's own copy of a package the app provides (what --relink would prune), and exit 0. Takes no package names; skips a checkout localized with --no-prune, and with --no-prune does nothing. Never runs npm; prints nothing when there is nothing to remove. For an app's npm pre* scripts (linked start, script, call and build-all already run it).\",\n )\n .option(\n '--reinstall <package>',\n \"npm install inside that package's checkout, then remove its own copies of what the app provides. Use this instead of running npm install in a checkout by hand.\",\n )\n .option('--dir <path>', 'Where checkouts live (default: packages-local).')\n .option(\n '--repo <git-url>',\n \"Clone this instead of the published repository, and record it. With --adopt: record this instead of the checkout's origin.\",\n )\n .option(\n '--subdir <path>',\n \"The package's directory inside the repository (monorepos).\",\n )\n .option(\n '--build <cmd>',\n 'Run this in the checkout after installing; a failure only warns. Defaults to `linked build`; pass an empty string to build nothing.',\n )\n .option(\n '--force',\n 'Overwrite a symlink pointing outside the checkout directory.',\n )\n .option(\n '--no-prune',\n \"Keep the checkout's node_modules as npm installed it. With a package to localize or --adopt, this is recorded in local-packages.json (prune: false), so --relink, --reinstall and the run-time check (--ensure, linked start etc.) leave that checkout alone too; localizing it again without --no-prune turns pruning back on. On --relink or --reinstall alone it applies to that run. By default a checkout's own copy of something the app provides is removed: a localized sibling, react or react-dom, or one of the checkout's own runtime dependencies that the app has at a version satisfying every range that would load it. The checkout then loads the app's copy instead of a second one. A copy the app's version does not satisfy, or whose own dependencies would resolve differently from the app, is kept and reported.\",\n )\n .action(async (packages: string[], options) => {\n const {runLocalize} = await import('./commands/localize.js');\n return runLocalize(packages, options);\n });\n\nprogram\n .command('delocalize [packages...]')\n .description(\n 'Undo localize: unlink the packages and forget them, keeping the checkout. With no names, undoes every localized package.',\n )\n .option('--purge', 'Also delete the checkout.')\n .option('--force', 'With --purge, delete even a checkout localize refuses.')\n .action(async (packages: string[], options) => {\n const {runDelocalize} = await import('./commands/localize.js');\n return runDelocalize(packages, options);\n });\n\nprogram\n .command('app-doctor')\n .description(\n \"Run in an app. Checks how the app uses linked packages: Vite pre-bundle entries that don't resolve (and the fix), linked packages whose dependencies don't support the app's React version (and which to bump), and hand-written entries that are now generated and can be removed. Exits 1 if anything needs fixing.\",\n )\n .action(async () => {\n const {runAppDoctor} = await import('./commands/app-doctor.js');\n return runAppDoctor();\n });\n\nprogram\n .command('setup-publish')\n .description(\n \"Set up the changesets publish pipeline in the current package repo. Writes the pr.yml/publish.yml callers of the shared workflows in the repo's own org .github repo, changesets config, .gitignore entries, and patches package.json.\",\n )\n .option(\n '--configure-github',\n 'Also apply the uniform branch protection on main and enable auto-merge (requires gh CLI installed and authenticated).',\n )\n .option(\n '--dual-branch',\n 'Deprecated and ignored: the main + dev flow and its @next prereleases are retired. Accepted only so stale scripts still set the repo up.',\n )\n .option(\n '--scope <scope>',\n 'Deprecated and ignored: the npm secret is NPM_AUTH_TOKEN in every org, holding that org\\'s own token. Accepted only so stale scripts still set the repo up.',\n )\n .option(\n '--grant-team <slug>',\n 'GitHub team slug to grant push access on the repo. Requires gh CLI.',\n )\n .action(async (options) => {\n const {setupPublish} = await import('./commands/setup-publish.js');\n await setupPublish({\n configureGithub: !!options.configureGithub,\n dualBranch: !!options.dualBranch,\n scope: options.scope,\n grantTeam: options.grantTeam,\n });\n });\n\nprogram\n .command('all [action] [filter] [filter-value]')\n .action((command, filter, filterValue) => {\n executeCommandForEachPackage(\n getLincdPackages(),\n command,\n filter,\n filterValue,\n );\n });\n// program.command('all-except [excludedSpaces] [action]').action((excludedSpaces, command) => {\n// executeCommandForEachModule(getLincdModules(), command, null, excludedSpaces);\n// });\n\nprogram.command('dev [target] [mode]').action((target, mode) => {\n developPackage(target, mode);\n});\n\nprogram.command('depcheck').action((target, mode) => {\n depCheck();\n});\nprogram.command('depcheck-staged').action((target, mode) => {\n depCheckStaged();\n});\nprogram\n .command('check-imports')\n .description(\n 'Check the imports of the package in the current folder. Exits 1 when an invalid import is found',\n )\n .action(async () => {\n try {\n await checkImports();\n } catch (report) {\n // checkImports throws the formatted report of every invalid import.\n console.error(typeof report === 'string' ? report : String(report));\n process.exitCode = 1;\n }\n });\n\nprogram\n .command('package')\n .action((name, command, args: string[]) => {\n let fullCommand = command\n ? command +\n ' ' +\n args\n .slice(0, 3)\n .filter((a) => a && true)\n .join(' ')\n : null;\n\n //TODO: call\n // let pkgName = process.argv[1];\n // console.log(pkgName);\n // let restArgs = process.argv.slice(2)\n // program.parse([],{from:'user'});\n // program.parse(['--port', '80'], { from: 'user' })\n\n executeCommandForPackage(name, fullCommand);\n })\n .alias('p')\n .alias('pkg')\n .alias('m')\n .alias('module')\n .description(\n 'Searches for a package in this workspace with a partially matching name and executes a command for that package (without needing to execute it from the folder of the package)',\n )\n .argument('<name>', 'the name of the package. Can be a part of the name.')\n .argument(\n '[command]',\n 'the linked command you want to execute. Like dev or build',\n )\n .argument('[args...]', 'the additional arguments of that command');\n\nprogram.command('enable-capacitor').action(() => {\n addCapacitor();\n});\n\n// One copy, always (localize/ensure.ts): before a command that runs the app's\n// code, remove any localized checkout's own copy of what the app provides.\ninstallOneCopyHook(program);\n\nconst unknownCommand = unknownCommandError(program, process.argv.slice(2));\nif (unknownCommand) {\n console.error(chalk.red(unknownCommand));\n process.exit(1);\n}\nprogram.parse(process.argv);\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AACA,oHAAoH;AACpH,yCAAyC;;;;;;;;;;AAEzC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,SAAS,EACT,eAAe,EACf,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,QAAQ,EACR,cAAc,EACd,cAAc,EACd,4BAA4B,EAC5B,wBAAwB,EACxB,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,QAAQ,EACR,SAAS,EACT,SAAS,EAET,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,4CAA4C;AAC5C,OAAO,EAAC,OAAO,EAAe,MAAM,WAAW,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I,CAAC;IAET,YAAY;IACZ,iCAAiC;IACjC,wBAAwB;IACxB,uCAAuC;IACvC,mCAAmC;IACnC,oDAAoD;IAEpD,wBAAwB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;AAC9C,CAAC,CAAC;KACD,KAAK,CAAC,GAAG,CAAC;KACV,KAAK,CAAC,KAAK,CAAC;KACZ,KAAK,CAAC,GAAG,CAAC;KACV,KAAK,CAAC,QAAQ,CAAC;KACf,WAAW,CACV,gLAAgL,CACjL;KACA,QAAQ,CAAC,QAAQ,EAAE,qDAAqD,CAAC;KACzE,QAAQ,CACP,WAAW,EACX,2DAA2D,CAC5D;KACA,QAAQ,CAAC,WAAW,EAAE,0CAA0C,CAAC,CAAC;AAErE,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE;IAC9C,YAAY,EAAE,CAAC;AACjB,CAAC,CAAC,CAAC;AAEH,8EAA8E;AAC9E,2EAA2E;AAC3E,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAE5B,MAAM,cAAc,GAAG,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3E,IAAI,cAAc,EAAE,CAAC;IACnB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;IACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC","sourcesContent":["#!/usr/bin/env tsx\n//The line above calls the TSX typescript executer as runtime, which extends node.js and supports running typescript\n// see: https://www.npmjs.com/package/tsx\n\nimport chalk from 'chalk';\nimport {\n addCapacitor,\n buildAll,\n buildPackage,\n buildUpdated,\n checkImports,\n compilePackage,\n createApp,\n createComponent,\n createOntology,\n createPackage,\n createSetComponent,\n createShape,\n depCheck,\n depCheckStaged,\n developPackage,\n executeCommandForEachPackage,\n executeCommandForPackage,\n getLincdPackages,\n getScriptDir,\n publishPackage,\n publishUpdated,\n register,\n runMethod,\n runScript,\n startServer,\n upgradePackages,\n} from './cli-methods.js';\n// import {buildMetadata} from './metadata';\nimport {program, type Command} from 'commander';\nimport {CreatePackageError} from './utils/createPackageLocation.js';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport 'require-extensions';\nimport {unknownCommandError} from './unknown-command.js';\nimport {installOneCopyHook} from './localize/one-copy-hook.js';\n\n/**\n * Run an async command action and report a failure the way the rest of this\n * CLI does — one red message and exit code 1 — instead of letting the rejection\n * escape the action and print a raw unhandled-rejection stack.\n */\nconst runAppCommand = async (run: () => Promise<unknown>): Promise<void> => {\n try {\n await run();\n } catch (error) {\n const message =\n error instanceof Error ? error.message : String(error ?? 'Unknown error');\n console.error(chalk.red(message));\n if (process.env.LINKED_DEBUG && error instanceof Error && error.stack) {\n console.error(error.stack);\n }\n process.exitCode = 1;\n }\n};\n\n/** `--env a,b` → `['a', 'b']`. */\nconst splitEnvOption = (value?: string): string[] =>\n (value || '')\n .split(',')\n .map((name) => name.trim())\n .filter(Boolean);\n\nprogram\n .command('create-app')\n .action((name, options) => {\n return createApp(name, process.cwd(), {\n appName: options.appName,\n appPrefix: options.appPrefix,\n appDomain: options.appDomain,\n skipInstall: options.skipInstall,\n template: options.template,\n }).catch((err) => {\n // Report and fail the process without cutting off pending output.\n console.error(chalk.red(err?.message ?? String(err)));\n process.exitCode = 1;\n });\n })\n .description(\n 'Creates a new folder with all the required files for a Linked app',\n )\n .argument(\n '<name>',\n 'the name of your Linked app. To use spaces, wrap the name in double quotes.',\n )\n .option('--app-name <name>', 'Display name for the app (skip interactive prompt)')\n .option('--app-prefix <prefix>', 'Short code prefix for data files (skip interactive prompt)')\n .option('--app-domain <domain>', 'Domain for the app (skip interactive prompt)')\n .option('--skip-install', 'Skip running npm install after scaffolding')\n .option(\n '--template <template>',\n 'App template: \"web\" (default) or \"react-native\"',\n );\n\nprogram\n .command('start')\n .action(async (options) => {\n const {startWithVite} = await import('./commands/start.js');\n return startWithVite({env: options?.env, apiOnly: options?.apiOnly});\n })\n .option('--env <env>', 'The node environment to use. Default is \"development\"')\n .option(\n '--api-only',\n 'Serve only the backend API: no vite.config, src/App.tsx or src/routes.tsx needed; page requests get a 404',\n )\n .description(\n 'Start the Linked dev server. Vite-backed by default.',\n );\n\nprogram\n .command('call')\n .action((packageName, method, options) => {\n return runMethod(packageName, method, {spawn: options.spawn});\n })\n .option(\n '--spawn',\n 'Start a new server instance instead of using an existing one',\n )\n .option('--env', 'The node environment to use. Default is \"development\"')\n .description(\n 'Start the Linked node.js server but without http server. Instead it immediately calls the specified method of the specified package and exits afterwards',\n )\n .argument(\n '<package>',\n 'the package of the backend provider that contains this method',\n )\n .argument('<method>', 'the name of the method you want to call');\n\nprogram\n .command('script')\n .action((scriptName, options) => {\n return runScript(scriptName, {spawn: options.spawn});\n })\n .option(\n '--spawn',\n 'Start a new server instance instead of using an existing one',\n )\n .option('--env', 'The node environment to use. Default is \"development\"')\n .description(\n 'Start the Linked node.js server but without http server. Instead it immediately runs the specified script and exits afterwards',\n )\n .argument(\n '<scriptName>',\n 'the name of the script file inside the /scripts folder',\n );\n\n/** A refusal of the create-* commands exits 1 with the message, not a stack. */\nconst reportRefusal = (e: unknown) => {\n if (!(e instanceof CreatePackageError)) throw e;\n console.error(chalk.red(e.message));\n process.exitCode = 1;\n};\n\nconst LOCATION_HELP =\n \"packages: part of this app's repository, a workspace member added to its dependencies. packages-local: its own git repository (git init + a first commit), linked and recorded by `linked localize` and not added to the app's dependencies until it is published.\";\nconst REMOTE_HELP =\n \"The new repository's origin; also written to repository.url. Implies --location packages-local.\";\nconst PUSH_HELP = 'Push the first commit to --remote.';\nconst SKIP_INSTALL_HELP = 'Write the files only: no install, no build, no git.';\nconst BASE_URI_HELP =\n \"The root the package's IRIs are minted under: linkedPackage(name, {baseUri}), shapes at <uri>shape/<package>/<Name>, ontology terms at <uri>ont/<slug>/<Term>. Inside an app it defaults to LINKED_BASE_URI from the environment, then the app's .env.local, then its .env; with none of them the package declares no root and falls back to https://linked.cm/.\";\nconst WHERE_HELP =\n \"Inside an app, it goes in packages/ (part of the app's repository) or packages-local/ (its own git repository, linked with `linked localize`); without --location, --remote or --push you are asked, on a terminal.\";\n\n/** The three scaffolding commands share the where-flags; `--kind` is create-package's own. */\nconst withPackageOptions = (command: Command) =>\n command\n .option('--location <where>', LOCATION_HELP)\n .option('--remote <git-url>', REMOTE_HELP)\n .option('--push', PUSH_HELP)\n .option('--skip-install', SKIP_INSTALL_HELP)\n .option('--base-uri <uri>', BASE_URI_HELP);\n\nwithPackageOptions(\n program\n .command('create-package')\n .action(async (name, uriBase, options) => {\n try {\n await createPackage(name, uriBase, process.cwd(), options);\n } catch (e) {\n reportRefusal(e);\n }\n })\n .description(\n 'Create a new Linked package: an ontology package (<name>-ont: one ontology, no shapes), an asset package (<name>-assets: shapes, components and a backend) or both. Without --kind you are asked, on a terminal. A name that already ends in -ont or -assets keeps it (foo-ont stays foo-ont). ' +\n WHERE_HELP,\n )\n .option(\n '--kind <kind>',\n 'ontology, assets or both. `both` creates <name>-ont and <name>-assets; it cannot take --remote (one repository cannot hold two packages).',\n )\n .argument(\n '<name>',\n 'The name of the package, without the kind suffix: the package is named <name>-ont or <name>-assets (a name that already ends in the suffix is kept). An npm scope is kept (@acme/foo → @acme/foo-ont).',\n )\n .argument(\n '[uri_base]',\n \"The namespace of the ontology package's ontology. Leave blank for https://linked.cm/ont/<name>/ (the ontology slug is <name>, without -ont).\",\n ),\n);\n\nwithPackageOptions(\n program\n .command('create-ont-package')\n .action(async (name, uriBase, options) => {\n try {\n await createPackage(name, uriBase, process.cwd(), {...options, kind: 'ontology'});\n } catch (e) {\n reportRefusal(e);\n }\n })\n .description(\n 'Create an ontology package <name>-ont: exactly one ontology (src/ontologies/<name>.ts), no shapes, components or backend. Its ontology slug is <name>, so its terms mint {root}ont/<name>/{Term}. A name that already ends in -ont keeps it. ' +\n WHERE_HELP,\n )\n .argument('<name>', 'The ontology slug; the package is named <name>-ont (foo-ont stays foo-ont).')\n .argument(\n '[uri_base]',\n 'The namespace of the ontology. Leave blank for https://linked.cm/ont/<name>/.',\n ),\n);\n\nwithPackageOptions(\n program\n .command('create-asset-package')\n .action(async (name, options) => {\n try {\n await createPackage(name, undefined, process.cwd(), {...options, kind: 'assets'});\n } catch (e) {\n reportRefusal(e);\n }\n })\n .description(\n 'Create an asset package <name>-assets: shapes, components and a backend (src/shapes, src/components, src/backend.ts), and no ontology. A name that already ends in -assets keeps it. ' +\n WHERE_HELP,\n )\n .argument('<name>', 'The package is named <name>-assets (foo-assets stays foo-assets).'),\n);\n\nprogram\n .command('upgrade-packages')\n .action(() => {\n return upgradePackages();\n })\n .description(\n 'Upgrade all linked packages in the workspace to ESM/CJS dual packages',\n );\n\nprogram\n .command('create-shape')\n .action((name, uriBase) => {\n return createShape(name).catch(reportRefusal);\n })\n .description(\n 'Creates a new ShapeClass file for your package. Execute this from your package folder (packages/<name>), not the app root: an app registers no package.',\n )\n .argument(\n '<name>',\n 'The name of the shape. Will be used for the file name and the class name',\n );\n\nprogram\n .command('create-component')\n .action((name, uriBase) => {\n return createComponent(name).catch(reportRefusal);\n })\n .description(\n 'Creates a new Component file for your package. Execute this from your package folder (packages/<name>), not the app root: an app registers no package.',\n )\n .argument(\n '<name>',\n 'The name of the component. Will be used for the file name and the export name',\n );\n\nprogram\n .command('create-set-component')\n .action((name, uriBase) => {\n return createSetComponent(name).catch(reportRefusal);\n })\n .description(\n 'Creates a new SetComponent file for your package. Execute this from your package folder.',\n )\n .argument(\n '<name>',\n 'The name of the component. Will be used for the file name and the export name',\n );\n\nprogram\n .command('create-ontology')\n .action((prefix, uriBase) => {\n return createOntology(prefix, uriBase).catch(reportRefusal);\n })\n .description(\n 'Creates a new ontology file for your package. Execute this from your package folder.',\n )\n .argument(\n '<suggested-prefix>',\n 'The suggested prefix for your ontology. Also the shorthand code used for the file name and the exported ontology object',\n )\n .argument(\n '[uribase]',\n \"Optional argument to set the URI base for the URI's of all entities in your ontology. Leave blank to use the URI's provided by lincd.org once you register this package\",\n );\n\nprogram.command('app [action]', {hidden: true}).action(() => {\n register('http://localhost:4101');\n});\nprogram.command('register-local', {hidden: true}).action(() => {\n register('http://localhost:4101');\n});\nprogram.command('register-dev', {hidden: true}).action(() => {\n register('https://dev-registry.lincd.org');\n});\nprogram\n .command('register')\n .action(() => {\n register('https://registry.lincd.org');\n })\n .description(\n 'Register (a new version of) this package to the Linked registry. If successful your package will appear on linked.cm',\n );\n\nprogram\n .command('info')\n .action(() => {\n let localDir = getScriptDir();\n let packageJsonPath = path.join(localDir, 'package.json');\n try {\n var ownPackage = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));\n } catch (e) {\n console.warn(\n 'Could not read package.json at ' + packageJsonPath + ': ' + e,\n );\n process.exit();\n }\n console.log(ownPackage.version);\n console.log('Running from: ' + localDir);\n })\n .description(\n \"Log the version of this tool and the path that it's running from\",\n );\n\nprogram\n .command('build [target] [target2]', {isDefault: true})\n .action(async (target, target2, options) => {\n const result = await buildPackage(target, target2, process.cwd(), !options?.silent);\n if (result !== true) {\n process.exitCode = 1;\n }\n })\n .option(\n '--silent',\n 'No output to console unless errors occur. The exit code is unaffected: 0 when the build succeeds (warnings included), 1 when it fails',\n );\n\nprogram\n .command('compile-only')\n .action(() => {\n compilePackage();\n })\n .description(\n 'Compile the package without other build steps. Run this command from the package folder',\n );\nprogram.command('build-metadata').action(() => {\n console.log('Needs to be reimplemented');\n // buildMetadata();\n});\nprogram\n .command('build-app')\n .action(async (options) => {\n // Vite is the only app build. An app without a `vite.config.{ts,js,mjs}`\n // is rejected by name rather than falling back to anything.\n await runAppCommand(async () => {\n const {assertViteApp, buildViteApp} = await import(\n './commands/build-app.js'\n );\n assertViteApp();\n await buildViteApp({\n environmentNames: splitEnvOption(options?.env),\n target: options?.target,\n publish: options?.publish === true,\n revision: options?.revision,\n allowDirty: options?.allowDirty === true,\n });\n });\n })\n .option('--env <env>', 'The node environment to use. Default is \"development\"')\n .option('--target <target>', 'Build target: web or capacitor')\n .option(\n '--publish',\n 'Upload the release after a successful web build (off by default; use `linked publish-app`)',\n )\n .option(\n '--revision <sha>',\n 'Revision identifying the release. Defaults to LINKED_RELEASE_REVISION, GITHUB_SHA, then git HEAD',\n )\n .option(\n '--allow-dirty',\n 'Build from a working tree with uncommitted changes; the release revision gets a \"-dirty\" suffix',\n )\n .description(\n 'Build the linked app frontend and backend for production, and write a release manifest. Requires a vite.config in the app root.',\n );\n\nprogram\n .command('publish-app')\n .option('--env <env>', 'The node environment to use')\n .option(\n '--manifest <path>',\n 'Release manifest to publish, relative to the app root. Default public/bundles/linked-release.json',\n )\n .option('--yes', 'Upload the verified release. Without it this is a dry run')\n .action(async (options) => {\n // Retry or inspect an existing release without rebuilding the app.\n await runAppCommand(async () => {\n const {ensureEnvironmentLoaded} = await import('./lifecycle.js');\n const {resolveAppAssetsStore} = await import(\n './app-release/app-assets-store.js'\n );\n const {publishApp} = await import('./commands/publish-app.js');\n await ensureEnvironmentLoaded(splitEnvOption(options?.env));\n // The store is resolved by publishApp, after the manifest is read.\n await publishApp({\n manifestPath: options?.manifest,\n resolveStore: () => resolveAppAssetsStore(),\n yes: options?.yes === true,\n });\n });\n })\n .description(\n 'Validate or retry publishing a previously built release. Defaults to dry run.',\n );\n\nprogram\n .command('serve-app')\n .option('--env <env>', 'The node environment to use')\n .action(async (options) => {\n // Production runtime loads compiled output and never starts Vite/HMR.\n await runAppCommand(async () => {\n const {serveCompiledApp} = await import('./commands/serve-app.js');\n await serveCompiledApp({environmentNames: splitEnvOption(options?.env)});\n });\n })\n .description('Start a compiled Linked app without Vite or HMR.');\n\nprogram.command('publish-updated').action(() => {\n return publishUpdated();\n});\nprogram.command('publish [version]').action((version) => {\n publishPackage(null, false, null, version);\n});\n\nprogram.command('status').action(() => {\n //log which packages need to be published\n return publishUpdated(true).then(() => {\n //log which packages need to be build\n return buildUpdated(undefined, '', '', true);\n });\n});\nprogram\n .command('build-updated [target] [target2]')\n .action((target, target2, options) => {\n const {useGit}: {useGit?: boolean} = options;\n return buildUpdated(1, target, target2, useGit || false);\n })\n .option(\n '--use-git',\n 'Use git commit timestamps to check which packages have been updated since the last build',\n );\nprogram\n .command('build-updated-since [num-commits-back] [target] [target2]')\n .action((back, target, target2) => {\n return buildUpdated(back, target, target2);\n });\nprogram\n .command('build-all')\n .action((options) => {\n buildAll(options);\n })\n .option(\n '--sync',\n 'build each package 1 by 1 - use this if you have build issues due to low available RAM memory',\n )\n .option('--from <char>', 'start from a specific package');\n\nprogram\n .command('build-workspace')\n .description(\n 'Build all linked packages in the current workspace in dependency order',\n )\n .option('-u, --updated', 'Only build updated packages')\n .option(\n '--use-git',\n 'Use git commit timestamps to determine which packages need updating',\n )\n .action(async (options) => {\n if (options.updated) {\n return buildUpdated(1, undefined, undefined, !!options.useGit);\n }\n return buildAll(options);\n });\n\nprogram\n .command('build-package <filepath>')\n .description(\n 'Given a file path, find its package.json and rebuild that package. Use for editor save hooks.',\n )\n .action(async (filepath) => {\n const {buildPackageByPath} = await import(\n './commands/build-package.js'\n );\n return buildPackageByPath(filepath);\n });\n\nprogram\n .command('localize [packages...]')\n .description(\n 'Develop an npm dependency from a git checkout: clone it, install inside the checkout, build it and symlink it into node_modules — without touching package.json or package-lock.json. Name packages exactly as npm names them (@_linked/rdfs, lodash); the repository is read from the published `repository` field. With no names, reports what is localized.',\n )\n .option('--list', 'Report what is localized rather than localizing anything.')\n .option(\n '--adopt',\n 'Link a checkout that is already in packages-local under its localize name (e.g. packages-local/_linked-foo for @_linked/foo): install, build, link and record it, without cloning or asking the registry. For a package created locally, or a clone put there by hand.',\n )\n .option(\n '--check',\n 'With --list: exit 1 when something recorded is not actually linked.',\n )\n .option(\n '--relink',\n 'Recreate the recorded symlinks. This is what a postinstall runs.',\n )\n .option(\n '--ensure',\n \"Remove every localized checkout's own copy of a package the app provides (what --relink would prune), and exit 0. Takes no package names; skips a checkout localized with --no-prune, and with --no-prune does nothing. Never runs npm; prints nothing when there is nothing to remove. For an app's npm pre* scripts (linked start, script, call and build-all already run it).\",\n )\n .option(\n '--reinstall <package>',\n \"npm install inside that package's checkout, then remove its own copies of what the app provides. Use this instead of running npm install in a checkout by hand.\",\n )\n .option('--dir <path>', 'Where checkouts live (default: packages-local).')\n .option(\n '--repo <git-url>',\n \"Clone this instead of the published repository, and record it. With --adopt: record this instead of the checkout's origin.\",\n )\n .option(\n '--subdir <path>',\n \"The package's directory inside the repository (monorepos).\",\n )\n .option(\n '--build <cmd>',\n 'Run this in the checkout after installing; a failure only warns. Defaults to `linked build`; pass an empty string to build nothing.',\n )\n .option(\n '--force',\n 'Overwrite a symlink pointing outside the checkout directory.',\n )\n .option(\n '--no-prune',\n \"Keep the checkout's node_modules as npm installed it. With a package to localize or --adopt, this is recorded in local-packages.json (prune: false), so --relink, --reinstall and the run-time check (--ensure, linked start etc.) leave that checkout alone too; localizing it again without --no-prune turns pruning back on. On --relink or --reinstall alone it applies to that run. By default a checkout's own copy of something the app provides is removed: a localized sibling, react or react-dom, or one of the checkout's own runtime dependencies that the app has at a version satisfying every range that would load it. The checkout then loads the app's copy instead of a second one. A copy the app's version does not satisfy, or whose own dependencies would resolve differently from the app, is kept and reported.\",\n )\n .action(async (packages: string[], options) => {\n const {runLocalize} = await import('./commands/localize.js');\n return runLocalize(packages, options);\n });\n\nprogram\n .command('delocalize [packages...]')\n .description(\n 'Undo localize: unlink the packages and forget them, keeping the checkout. With no names, undoes every localized package.',\n )\n .option('--purge', 'Also delete the checkout.')\n .option('--force', 'With --purge, delete even a checkout localize refuses.')\n .action(async (packages: string[], options) => {\n const {runDelocalize} = await import('./commands/localize.js');\n return runDelocalize(packages, options);\n });\n\nprogram\n .command('app-doctor')\n .description(\n \"Run in an app. Checks how the app uses linked packages: Vite pre-bundle entries that don't resolve (and the fix), linked packages whose dependencies don't support the app's React version (and which to bump), and hand-written entries that are now generated and can be removed. Exits 1 if anything needs fixing.\",\n )\n .action(async () => {\n const {runAppDoctor} = await import('./commands/app-doctor.js');\n return runAppDoctor();\n });\n\nprogram\n .command('setup-publish')\n .description(\n \"Set up the changesets publish pipeline in the current package repo. Writes the pr.yml/publish.yml callers of the shared workflows in the repo's own org .github repo, changesets config, .gitignore entries, and patches package.json.\",\n )\n .option(\n '--configure-github',\n 'Also apply the uniform branch protection on main and enable auto-merge (requires gh CLI installed and authenticated).',\n )\n .option(\n '--dual-branch',\n 'Deprecated and ignored: the main + dev flow and its @next prereleases are retired. Accepted only so stale scripts still set the repo up.',\n )\n .option(\n '--scope <scope>',\n 'Deprecated and ignored: the npm secret is NPM_AUTH_TOKEN in every org, holding that org\\'s own token. Accepted only so stale scripts still set the repo up.',\n )\n .option(\n '--grant-team <slug>',\n 'GitHub team slug to grant push access on the repo. Requires gh CLI.',\n )\n .action(async (options) => {\n const {setupPublish} = await import('./commands/setup-publish.js');\n await setupPublish({\n configureGithub: !!options.configureGithub,\n dualBranch: !!options.dualBranch,\n scope: options.scope,\n grantTeam: options.grantTeam,\n });\n });\n\nprogram\n .command('all [action] [filter] [filter-value]')\n .action((command, filter, filterValue) => {\n executeCommandForEachPackage(\n getLincdPackages(),\n command,\n filter,\n filterValue,\n );\n });\n// program.command('all-except [excludedSpaces] [action]').action((excludedSpaces, command) => {\n// executeCommandForEachModule(getLincdModules(), command, null, excludedSpaces);\n// });\n\nprogram.command('dev [target] [mode]').action((target, mode) => {\n developPackage(target, mode);\n});\n\nprogram.command('depcheck').action((target, mode) => {\n depCheck();\n});\nprogram.command('depcheck-staged').action((target, mode) => {\n depCheckStaged();\n});\nprogram\n .command('check-imports')\n .description(\n 'Check the imports of the package in the current folder. Exits 1 when an invalid import is found',\n )\n .action(async () => {\n try {\n await checkImports();\n } catch (report) {\n // checkImports throws the formatted report of every invalid import.\n console.error(typeof report === 'string' ? report : String(report));\n process.exitCode = 1;\n }\n });\n\nprogram\n .command('package')\n .action((name, command, args: string[]) => {\n let fullCommand = command\n ? command +\n ' ' +\n args\n .slice(0, 3)\n .filter((a) => a && true)\n .join(' ')\n : null;\n\n //TODO: call\n // let pkgName = process.argv[1];\n // console.log(pkgName);\n // let restArgs = process.argv.slice(2)\n // program.parse([],{from:'user'});\n // program.parse(['--port', '80'], { from: 'user' })\n\n executeCommandForPackage(name, fullCommand);\n })\n .alias('p')\n .alias('pkg')\n .alias('m')\n .alias('module')\n .description(\n 'Searches for a package in this workspace with a partially matching name and executes a command for that package (without needing to execute it from the folder of the package)',\n )\n .argument('<name>', 'the name of the package. Can be a part of the name.')\n .argument(\n '[command]',\n 'the linked command you want to execute. Like dev or build',\n )\n .argument('[args...]', 'the additional arguments of that command');\n\nprogram.command('enable-capacitor').action(() => {\n addCapacitor();\n});\n\n// One copy, always (localize/ensure.ts): before a command that runs the app's\n// code, remove any localized checkout's own copy of what the app provides.\ninstallOneCopyHook(program);\n\nconst unknownCommand = unknownCommandError(program, process.argv.slice(2));\nif (unknownCommand) {\n console.error(chalk.red(unknownCommand));\n process.exit(1);\n}\nprogram.parse(process.argv);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"localize.d.ts","sourceRoot":"","sources":["../../../src/localize/localize.ts"],"names":[],"mappings":"AA+CA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,UAAU,CAAC;AAInC,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AAW7C;;;;;;;GAOG;AACH,MAAM,WAAW,eAAgB,SAAQ,YAAY;IACnD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,iFAAiF;IACjF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,uDAAuD;AACvD,MAAM,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,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,EACrC,IAAI,EAAE,IAAI,GACT,MAAM,CAUR;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,MAAM,CAMzE;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAU/D;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,GAC1B,MAAM,GAAG,SAAS,CAQpB"}
@@ -25,8 +25,15 @@
25
25
  * installed package cannot give you something to edit.
26
26
  *
27
27
  * What localize NEVER does: run an install at the consumer root, or edit
28
- * `package.json`, `package-lock.json`, `.gitignore`, `workspaces` or any
29
- * bundler config. It asserts it did not before exiting 0.
28
+ * `package-lock.json`, `.gitignore`, `workspaces`, dependencies or any
29
+ * bundler config. It asserts the work did not touch `package.json` or
30
+ * `package-lock.json` before exiting 0.
31
+ *
32
+ * The one deliberate edit, made after that assertion: when a run records a
33
+ * package, the app's `postinstall` and `dependencies` scripts get
34
+ * `linked localize --relink` if they lack it (`../utils/relinkHooks.ts`
35
+ * explains why npm needs both). Without them the next npm command silently
36
+ * undoes the link this run just made.
30
37
  */
31
38
  import fs from 'node:fs';
32
39
  import path from 'node:path';
@@ -35,6 +42,7 @@ import { DEFAULT_DIR, SCHEMA_VERSION, readManifest, writeManifest, } from './man
35
42
  import { checkoutNameFor, resolvePackage } from './resolve.js';
36
43
  import { pruneProvided, shouldPrune } from './prune.js';
37
44
  import { ensure } from './ensure.js';
45
+ import { ensureRelinkHooksInFile, RELINK_COMMAND } from '../utils/relinkHooks.js';
38
46
  import { diffManifests, isGitCheckout, isInside, isSymlink, readJson, snapshotManifests, writeLink, } from './fsops.js';
39
47
  export function localize(names, opts, deps) {
40
48
  return forEachName(names, opts, deps, localizeOne);
@@ -62,11 +70,14 @@ export function forEachName(names, opts, deps, one) {
62
70
  const dir = (_b = (_a = opts.dir) !== null && _a !== void 0 ? _a : manifest.dir) !== null && _b !== void 0 ? _b : DEFAULT_DIR;
63
71
  const entries = Object.assign({}, manifest.entries);
64
72
  let code = 0;
73
+ let recorded = false;
65
74
  for (const name of names) {
66
75
  try {
67
76
  const result = one(name, dir, entries[name], opts, deps);
68
- if (result.entry)
77
+ if (result.entry) {
69
78
  entries[result.entry.name] = result.entry.value;
79
+ recorded = true;
80
+ }
70
81
  code = Math.max(code, result.code);
71
82
  // Written after EACH name, so an interruption keeps what already worked.
72
83
  writeManifest(deps.appRoot, {
@@ -92,8 +103,19 @@ export function forEachName(names, opts, deps, one) {
92
103
  }
93
104
  code = Math.max(code, assertLinked(entries, deps));
94
105
  code = Math.max(code, assertManifestsUntouched(before, deps));
106
+ // After the assertion, so it still covers everything the work itself did.
107
+ if (recorded)
108
+ ensureRelinkHooksIn(deps);
95
109
  return code;
96
110
  }
111
+ /** Add the relink hooks to the app's package.json when it lacks them. See relinkHooks.ts. */
112
+ function ensureRelinkHooksIn(deps) {
113
+ const added = ensureRelinkHooksInFile(path.join(deps.appRoot, 'package.json'));
114
+ if (!added.length)
115
+ return;
116
+ deps.log(`[localize] Added \`${RELINK_COMMAND}\` to the app's ${added.join(' and ')} ` +
117
+ `script${added.length > 1 ? 's' : ''} so npm keeps the links`);
118
+ }
97
119
  function localizeOne(name, dir, recorded, opts, deps) {
98
120
  var _a;
99
121
  // An override recorded by an earlier run is reused, so `--repo` is a
@@ -1 +1 @@
1
- {"version":3,"file":"localize.js","sourceRoot":"","sources":["../../../src/localize/localize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,mBAAmB,EACnB,cAAc,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AAC;AACV,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,IAAU;IACrD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE;QACrE,GAAG,EAAE,KAAK;KACX,CAAC,CAAC;IACH,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE;QAAE,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IACpE,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE;QAC/D,GAAG,EAAE,KAAK;KACX,CAAC,CAAC;IACH,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC1B,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,IAAY,EACZ,IAA2B;;IAE3B,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;IAC9D,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IAC3B,OAAO,CACL,MAAA,MAAA,MAAA,GAAG,CAAC,YAAY,0CAAG,IAAI,CAAC,mCACxB,MAAA,GAAG,CAAC,eAAe,0CAAG,IAAI,CAAC,mCAC3B,MAAA,GAAG,CAAC,oBAAoB,0CAAG,IAAI,CAAC,CACjC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * `localize` -- turn an npm-installed dependency into an editable git checkout.\n *\n * The loop, in five steps, none of which involve npm learning anything:\n *\n * 1. npm name -> registry `repository` (see resolve.ts)\n * 2. `git clone` into `<dir>/<name>`\n * 3. **`npm install` INSIDE the checkout**, then prune it (`ensure`)\n * 4. `fs.symlink` node_modules/<name> -> the checkout\n * 5. record it in a gitignored manifest\n *\n * `adopt` (adopt.ts) enters at step 3 with a checkout that is already there,\n * and shares everything from there on: `forEachName` and `installLinkAndRecord`\n * below.\n *\n * Step 3 is the one that is easy to \"simplify\" and must not be. Installing\n * from the parent instead -- `npm install <path> --no-save` -- hard-failed an\n * app's boot on a missing peer dependency, because module resolution happens\n * from the symlink's REAL path, whose ancestors have no `node_modules`. The\n * checkout needs its own installed tree. `tests/unit/localize/real-localize.test.ts` runs a\n * real clone and a real install and asserts the dependency landed inside the\n * checkout, so a reimplementation that moves the install back out fails there.\n *\n * A clone, not a copy: a published tarball has no `src/`, so copying the\n * installed package cannot give you something to edit.\n *\n * What localize NEVER does: run an install at the consumer root, or edit\n * `package.json`, `package-lock.json`, `.gitignore`, `workspaces` or any\n * bundler config. It asserts it did not before exiting 0.\n */\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport {\n EXIT_INSTALL_FAILED,\n EXIT_NOT_FOUND,\n EXIT_MANIFEST_DIRTY,\n EXIT_REFUSED,\n EXIT_WARNED,\n LocalizeError,\n} from './errors.js';\nimport {\n DEFAULT_DIR,\n SCHEMA_VERSION,\n readManifest,\n writeManifest,\n} from './manifest.js';\nimport type {ManifestEntry} from './manifest.js';\nimport type {Deps} from './run.js';\nimport {checkoutNameFor, resolvePackage} from './resolve.js';\nimport {pruneProvided, shouldPrune} from './prune.js';\nimport {ensure} from './ensure.js';\nimport type {PruneOptions} from './prune.js';\nimport {\n diffManifests,\n isGitCheckout,\n isInside,\n isSymlink,\n readJson,\n snapshotManifests,\n writeLink,\n} from './fsops.js';\n\n/**\n * @param {string[]} names full npm package names\n * @param {object} opts `{force, dir, repo, subdir, build, prune}` -- `prune`\n * defaults to true; see prune.ts\n * @param {object} deps `{appRoot, run, log, warn, error}`\n * @returns {number} the process exit code: the HIGHEST of the per-name codes,\n * since each name is atomic and a failure on name 2 does not undo name 1.\n */\nexport interface LocalizeOptions extends PruneOptions {\n force?: boolean;\n /** Where checkouts live, relative to the app root (default `packages-local`). */\n dir?: string;\n repo?: string;\n subdir?: string;\n /** Run in the checkout after installing; absent or empty runs nothing. */\n build?: string;\n}\n\n/** What one name's work returns to the shared loop. */\nexport interface OneResult {\n code: number;\n entry?: {name: string; value: ManifestEntry};\n}\n\nexport type OneName = (\n name: string,\n dir: string,\n recorded: ManifestEntry | undefined,\n opts: LocalizeOptions,\n deps: Deps,\n) => OneResult;\n\nexport function localize(\n names: string[],\n opts: LocalizeOptions,\n deps: Deps,\n): number {\n return forEachName(names, opts, deps, localizeOne);\n}\n\n/**\n * The loop `localize` and `adopt` share: read the manifest once, run `one` per\n * name, write the manifest after each, then assert the links and the\n * consumer's untouched manifests.\n *\n * @param {(name: string, dir: string, recorded: object|undefined, opts: object, deps: object)\n * => {code: number, entry?: {name: string, value: object}}} one\n */\nexport function forEachName(\n names: string[],\n opts: LocalizeOptions,\n deps: Deps,\n one: OneName,\n): number {\n // Taken BEFORE anything runs: the post-condition is about what THIS run\n // changed, not about what the tree looked like at HEAD.\n const before = snapshotManifests(deps.appRoot);\n\n let manifest;\n try {\n manifest = readManifest(deps.appRoot, deps);\n } catch (e) {\n return reportError(e, deps);\n }\n\n const dir = opts.dir ?? manifest.dir ?? DEFAULT_DIR;\n const entries = {...manifest.entries};\n let code = 0;\n\n for (const name of names) {\n try {\n const result = one(name, dir, entries[name], opts, deps);\n if (result.entry) entries[result.entry.name] = result.entry.value;\n code = Math.max(code, result.code);\n // Written after EACH name, so an interruption keeps what already worked.\n writeManifest(deps.appRoot, {\n version: SCHEMA_VERSION,\n dir,\n packages: entries,\n });\n } catch (e) {\n code = Math.max(code, reportError(e, deps));\n }\n }\n\n // Over EVERY localized checkout, not just the ones named: localizing `B`\n // is what makes `A`'s registry copy of `B` redundant.\n if (shouldPrune(opts)) {\n try {\n pruneProvided(entries, opts, deps);\n } catch (e) {\n deps.warn(\n `[localize] pruning failed, the checkouts' node_modules are as npm left them: ${e.message}`,\n );\n code = Math.max(code, EXIT_WARNED);\n }\n }\n\n code = Math.max(code, assertLinked(entries, deps));\n code = Math.max(code, assertManifestsUntouched(before, deps));\n return code;\n}\n\nfunction localizeOne(\n name: string,\n dir: string,\n recorded: ManifestEntry | undefined,\n opts: LocalizeOptions,\n deps: Deps,\n): OneResult {\n // An override recorded by an earlier run is reused, so `--repo` is a\n // one-time cost rather than something to remember on every invocation.\n const override = opts.repo\n ? {repo: opts.repo, subdir: opts.subdir}\n : recorded?.repo && !looksLikeOrgSlug(recorded.repo)\n ? {repo: recorded.repo, subdir: recorded.subdir}\n : undefined;\n\n const resolved = resolveOrSuggestAdopt(name, dir, override, deps);\n let code = 0;\n\n const relClone = path.join(dir, resolved.checkoutName);\n const clone = path.join(deps.appRoot, relClone);\n // When the repository holds more than this package, the CHECKOUT is the\n // clone but the PACKAGE is a directory inside it: that is where the install\n // runs and that is what the symlink points at.\n const relPkg = resolved.subdir\n ? path.join(relClone, resolved.subdir)\n : relClone;\n const pkgDir = path.join(deps.appRoot, relPkg);\n\n guardForeignLink(resolved.npmName, dir, opts, deps);\n\n if (isGitCheckout(clone)) {\n code = Math.max(code, refresh(relClone, clone, deps));\n if (code === EXIT_WARNED) return {code}; // a non-fast-forward is reported, never forced\n } else {\n fs.mkdirSync(path.dirname(clone), {recursive: true});\n deps.log(`[localize] cloning ${resolved.repo} -> ${relClone}`);\n const r = deps.run('git', ['clone', resolved.repo, clone]);\n if (r.status !== 0) {\n throw new LocalizeError(\n `git clone ${resolved.repo} failed:\\n${(r.stderr || r.stdout).trim()}`,\n EXIT_REFUSED,\n );\n }\n }\n\n if (!fs.existsSync(path.join(pkgDir, 'package.json'))) {\n throw new LocalizeError(\n `${relPkg} has no package.json, so it is not the package \"${name}\".\\n` +\n (resolved.subdir\n ? `The registry says \"${name}\" lives in \"${resolved.subdir}\" of ${resolved.repo}, and it does not.`\n : `${resolved.repo} looks like a monorepo root. Say where the package lives:\\n` +\n ` linked localize ${name} --repo ${resolved.repo} --subdir <path-inside-the-repo>`),\n EXIT_REFUSED,\n );\n }\n\n // The checkout's own package.json is authoritative about the name: a\n // mismatch means the symlink would be written under a name nothing imports.\n const declared = readJson(path.join(pkgDir, 'package.json'))?.name;\n if (declared && declared !== resolved.npmName) {\n throw new LocalizeError(\n `${relPkg} declares itself as \"${declared}\", not \"${name}\".\\n` +\n (resolved.subdir\n ? `The registry's repository.directory for \"${name}\" points at the wrong package.`\n : `${resolved.repo} is probably a monorepo. Point at the right directory:\\n` +\n ` linked localize ${name} --repo ${resolved.repo} --subdir <path-inside-the-repo>`),\n EXIT_REFUSED,\n );\n }\n\n return installLinkAndRecord(\n {\n npmName: resolved.npmName,\n clone,\n relPkg,\n pkgDir,\n repo: resolved.repo,\n subdir: resolved.subdir,\n },\n opts,\n deps,\n code,\n );\n}\n\n/**\n * Everything after the checkout exists, shared by `localize` and `adopt`:\n * install inside it, run the configured build, link it, and describe the\n * manifest entry. Nothing here knows how the checkout got there.\n *\n * `repo` may be absent -- an adopted checkout with no remote is recorded\n * without one.\n */\nexport function installLinkAndRecord(\n {\n npmName,\n clone,\n relPkg,\n pkgDir,\n repo,\n subdir,\n }: {\n npmName: string;\n clone: string;\n relPkg: string;\n pkgDir: string;\n repo?: string;\n subdir?: string;\n },\n opts: LocalizeOptions,\n deps: Deps,\n code = 0,\n): {code: number; entry: {name: string; value: ManifestEntry}} {\n // THE constraint. Read the module header before changing this. `ensure`\n // installs inside the checkout and prunes it as one step (ensure.ts).\n try {\n code = Math.max(code, ensure({path: relPkg, subdir}, deps, opts));\n } catch (e) {\n if (e instanceof LocalizeError && e.code === EXIT_INSTALL_FAILED)\n e.message += `\\nThe checkout is left on disk. Nothing was linked and nothing was recorded.`;\n throw e;\n }\n\n // The build is the one thing localize does not know how to do, so it is\n // configuration rather than behaviour. A failure is a WARNING: a package\n // whose build is broken is exactly what you are about to fix, and refusing\n // to link it would be perverse.\n if (runBuild(relPkg, pkgDir, opts, deps) === 'failed')\n code = Math.max(code, EXIT_WARNED);\n\n writeLink(deps.appRoot, npmName, pkgDir);\n const branch = currentBranch(clone, deps);\n deps.log(`[localize] linked ${npmName} -> ${relPkg} (branch ${branch})`);\n\n const range = declaredRange(npmName, deps);\n return {\n code,\n entry: {\n name: npmName,\n value: {\n ...(repo ? {repo} : {}),\n path: relPkg,\n branch,\n ...(subdir ? {subdir} : {}),\n ...(range ? {range} : {}),\n // `--no-prune` is remembered, so the run-time check and `--relink` honour it too.\n ...(shouldPrune(opts) ? {} : {prune: false as const}),\n },\n },\n };\n}\n\n/**\n * A registry lookup that fails while a git checkout already sits where the\n * clone would go is almost always a package that was never published -- one\n * made locally. Say how to link it as it is rather than leave the developer\n * guessing at a `--repo`.\n */\nfunction resolveOrSuggestAdopt(name, dir, override, deps) {\n try {\n return resolvePackage(name, deps, override);\n } catch (e) {\n const relClone = path.join(dir, checkoutNameFor(name));\n if (\n e instanceof LocalizeError &&\n e.code === EXIT_NOT_FOUND &&\n isGitCheckout(path.join(deps.appRoot, relClone))\n ) {\n e.message +=\n `\\n${relClone} is already a git checkout. To link it as it is, with no registry lookup:\\n` +\n ` linked localize ${name} --adopt`;\n }\n throw e;\n }\n}\n\n/** Older manifests recorded `owner/repo`; those are re-resolved rather than cloned blind. */\nfunction looksLikeOrgSlug(repo) {\n return /^[\\w.-]+\\/[\\w.-]+$/.test(repo);\n}\n\n/**\n * Reuse an existing clone. A dirty tree is reused WITHOUT pulling and said so;\n * a clean one is fast-forwarded; a non-fast-forward is reported and skipped\n * rather than forced, because the developer's commits are the entire point.\n */\nfunction refresh(relPath, clone, deps) {\n const status = deps.run('git', ['status', '--porcelain'], {cwd: clone});\n const modified = status.stdout.split('\\n').filter((l) => l.trim()).length;\n if (modified > 0) {\n deps.log(\n `[localize] ${relPath}: ${modified} modified file${modified === 1 ? '' : 's'} — not pulling`,\n );\n return 0;\n }\n const pull = deps.run('git', ['pull', '--ff-only'], {cwd: clone});\n if (pull.status !== 0) {\n deps.warn(\n `[localize] ${relPath}: \\`git pull --ff-only\\` failed (not a fast-forward) — skipped, not ` +\n `forced. Reconcile it by hand:\\n${(pull.stderr || pull.stdout).trim()}`,\n );\n return EXIT_WARNED;\n }\n return 0;\n}\n\n/**\n * Run the configured build command, if there is one.\n *\n * localize has no opinion about how a checkout is built, and does not look for\n * a builder. `--build \"<cmd>\"`, or a `build` field in the manifest, or\n * `{build}` in the programmatic options. Absent -- the common case, and the\n * case for anything whose dev loop reads source directly -- nothing runs and\n * nothing is said.\n */\nfunction runBuild(relPath, pkgDir, opts, deps) {\n const cmd = opts.build;\n if (!cmd) return 'skipped';\n deps.log(`[localize] ${relPath}: ${cmd}`);\n const r = deps.run(cmd, [], {cwd: pkgDir, shell: true});\n if (r.status !== 0) {\n deps.warn(\n `[localize] ${relPath}: \\`${cmd}\\` failed. The package is linked and recorded anyway — ` +\n `a package whose build is broken is exactly what you are about to fix.\\n` +\n `${(r.stderr || r.stdout).trim()}`,\n );\n return 'failed';\n }\n return 'ok';\n}\n\n/** Refuse when `node_modules/<name>` is already a symlink pointing outside `<dir>`. */\nexport function guardForeignLink(\n npmName: string,\n dir: string,\n opts: {force?: boolean},\n deps: Deps,\n): void {\n const link = path.join(deps.appRoot, 'node_modules', npmName);\n if (!isSymlink(link)) return;\n let target;\n try {\n target = fs.realpathSync(link);\n } catch {\n return; // a dangling link is ours to replace\n }\n if (isInside(target, path.join(deps.appRoot, dir))) return;\n if (opts.force) {\n deps.warn(\n `[localize] --force: overwriting the existing link ${npmName} -> ${target}`,\n );\n return;\n }\n throw new LocalizeError(\n `node_modules/${npmName} is already a symlink to ${target}, which is outside ${dir}.\\n` +\n `Refusing to overwrite someone else's link. Pass --force to replace it.`,\n EXIT_REFUSED,\n );\n}\n\n/** Every recorded package is actually linked where the manifest says it is. */\nfunction assertLinked(entries: Record<string, ManifestEntry>, deps: Deps) {\n let code = 0;\n for (const [name, entry] of Object.entries(entries)) {\n const link = path.join(deps.appRoot, 'node_modules', name);\n const expected = path.join(deps.appRoot, entry.path);\n if (!isSymlink(link)) {\n deps.warn(\n `[localize] ${name} is recorded but node_modules/${name} is not a symlink.`,\n );\n code = Math.max(code, EXIT_WARNED);\n continue;\n }\n if (!fs.existsSync(expected)) continue; // \"checkout missing\" is a --list state, not a failure\n if (fs.realpathSync(link) !== fs.realpathSync(expected)) {\n deps.warn(\n `[localize] ${name} links to ${fs.realpathSync(link)} but the manifest records ${entry.path}.`,\n );\n code = Math.max(code, EXIT_WARNED);\n }\n }\n return code;\n}\n\n/**\n * The property the whole design rests on: this run changed neither manifest.\n *\n * Content hashes, not `git status`. `git status` compares against HEAD, so in\n * any tree with an uncommitted `package.json` it reports a modification the\n * command did not make -- an earlier tool shipped exactly that and reported\n * correct runs as failures.\n */\nexport function assertManifestsUntouched(\n before: Record<string, string | null>,\n deps: Deps,\n): number {\n const changed = diffManifests(before, snapshotManifests(deps.appRoot));\n if (!changed.length) return 0;\n deps.error(\n `[localize] the consumer's manifests changed while this command ran:\\n` +\n changed.map((c) => ` ${c}`).join('\\n') +\n `\\nThis is the exact failure localize exists to prevent. Revert those files; nothing in ` +\n `localize is supposed to touch them.`,\n );\n return EXIT_MANIFEST_DIRTY;\n}\n\nexport function reportError(e: unknown, deps: Pick<Deps, 'error'>): number {\n if (e instanceof LocalizeError) {\n deps.error(`[localize] ${e.message}`);\n return e.code;\n }\n throw e;\n}\n\n/**\n * The checked-out branch, or `HEAD` when detached. `symbolic-ref` first,\n * because it also names the branch of a repository with no commits yet --\n * `rev-parse --abbrev-ref` fails there, and `create-package` adopts a fresh\n * `git init` before its first commit.\n */\nexport function currentBranch(clone: string, deps: Deps): string {\n const sym = deps.run('git', ['symbolic-ref', '--short', '-q', 'HEAD'], {\n cwd: clone,\n });\n if (sym.status === 0 && sym.stdout.trim()) return sym.stdout.trim();\n const r = deps.run('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {\n cwd: clone,\n });\n const b = r.stdout.trim();\n return r.status === 0 && b ? b : 'HEAD';\n}\n\nexport function declaredRange(\n name: string,\n deps: Pick<Deps, 'appRoot'>,\n): string | undefined {\n const pkg = readJson(path.join(deps.appRoot, 'package.json'));\n if (!pkg) return undefined;\n return (\n pkg.dependencies?.[name] ??\n pkg.devDependencies?.[name] ??\n pkg.optionalDependencies?.[name]\n );\n}\n"]}
1
+ {"version":3,"file":"localize.js","sourceRoot":"","sources":["../../../src/localize/localize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,WAAW,EACX,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,WAAW,EACX,cAAc,EACd,YAAY,EACZ,aAAa,GACd,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAC,eAAe,EAAE,cAAc,EAAC,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,YAAY,CAAC;AACtD,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAC,uBAAuB,EAAE,cAAc,EAAC,MAAM,yBAAyB,CAAC;AAChF,OAAO,EACL,aAAa,EACb,aAAa,EACb,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,iBAAiB,EACjB,SAAS,GACV,MAAM,YAAY,CAAC;AAkCpB,MAAM,UAAU,QAAQ,CACtB,KAAe,EACf,IAAqB,EACrB,IAAU;IAEV,OAAO,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CACzB,KAAe,EACf,IAAqB,EACrB,IAAU,EACV,GAAY;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AG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE;QACrE,GAAG,EAAE,KAAK;KACX,CAAC,CAAC;IACH,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE;QAAE,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IACpE,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE;QAC/D,GAAG,EAAE,KAAK;KACX,CAAC,CAAC;IACH,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC1B,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,IAAY,EACZ,IAA2B;;IAE3B,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;IAC9D,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IAC3B,OAAO,CACL,MAAA,MAAA,MAAA,GAAG,CAAC,YAAY,0CAAG,IAAI,CAAC,mCACxB,MAAA,GAAG,CAAC,eAAe,0CAAG,IAAI,CAAC,mCAC3B,MAAA,GAAG,CAAC,oBAAoB,0CAAG,IAAI,CAAC,CACjC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * `localize` -- turn an npm-installed dependency into an editable git checkout.\n *\n * The loop, in five steps, none of which involve npm learning anything:\n *\n * 1. npm name -> registry `repository` (see resolve.ts)\n * 2. `git clone` into `<dir>/<name>`\n * 3. **`npm install` INSIDE the checkout**, then prune it (`ensure`)\n * 4. `fs.symlink` node_modules/<name> -> the checkout\n * 5. record it in a gitignored manifest\n *\n * `adopt` (adopt.ts) enters at step 3 with a checkout that is already there,\n * and shares everything from there on: `forEachName` and `installLinkAndRecord`\n * below.\n *\n * Step 3 is the one that is easy to \"simplify\" and must not be. Installing\n * from the parent instead -- `npm install <path> --no-save` -- hard-failed an\n * app's boot on a missing peer dependency, because module resolution happens\n * from the symlink's REAL path, whose ancestors have no `node_modules`. The\n * checkout needs its own installed tree. `tests/unit/localize/real-localize.test.ts` runs a\n * real clone and a real install and asserts the dependency landed inside the\n * checkout, so a reimplementation that moves the install back out fails there.\n *\n * A clone, not a copy: a published tarball has no `src/`, so copying the\n * installed package cannot give you something to edit.\n *\n * What localize NEVER does: run an install at the consumer root, or edit\n * `package-lock.json`, `.gitignore`, `workspaces`, dependencies or any\n * bundler config. It asserts the work did not touch `package.json` or\n * `package-lock.json` before exiting 0.\n *\n * The one deliberate edit, made after that assertion: when a run records a\n * package, the app's `postinstall` and `dependencies` scripts get\n * `linked localize --relink` if they lack it (`../utils/relinkHooks.ts`\n * explains why npm needs both). Without them the next npm command silently\n * undoes the link this run just made.\n */\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport {\n EXIT_INSTALL_FAILED,\n EXIT_NOT_FOUND,\n EXIT_MANIFEST_DIRTY,\n EXIT_REFUSED,\n EXIT_WARNED,\n LocalizeError,\n} from './errors.js';\nimport {\n DEFAULT_DIR,\n SCHEMA_VERSION,\n readManifest,\n writeManifest,\n} from './manifest.js';\nimport type {ManifestEntry} from './manifest.js';\nimport type {Deps} from './run.js';\nimport {checkoutNameFor, resolvePackage} from './resolve.js';\nimport {pruneProvided, shouldPrune} from './prune.js';\nimport {ensure} from './ensure.js';\nimport type {PruneOptions} from './prune.js';\nimport {ensureRelinkHooksInFile, RELINK_COMMAND} from '../utils/relinkHooks.js';\nimport {\n diffManifests,\n isGitCheckout,\n isInside,\n isSymlink,\n readJson,\n snapshotManifests,\n writeLink,\n} from './fsops.js';\n\n/**\n * @param {string[]} names full npm package names\n * @param {object} opts `{force, dir, repo, subdir, build, prune}` -- `prune`\n * defaults to true; see prune.ts\n * @param {object} deps `{appRoot, run, log, warn, error}`\n * @returns {number} the process exit code: the HIGHEST of the per-name codes,\n * since each name is atomic and a failure on name 2 does not undo name 1.\n */\nexport interface LocalizeOptions extends PruneOptions {\n force?: boolean;\n /** Where checkouts live, relative to the app root (default `packages-local`). */\n dir?: string;\n repo?: string;\n subdir?: string;\n /** Run in the checkout after installing; absent or empty runs nothing. */\n build?: string;\n}\n\n/** What one name's work returns to the shared loop. */\nexport interface OneResult {\n code: number;\n entry?: {name: string; value: ManifestEntry};\n}\n\nexport type OneName = (\n name: string,\n dir: string,\n recorded: ManifestEntry | undefined,\n opts: LocalizeOptions,\n deps: Deps,\n) => OneResult;\n\nexport function localize(\n names: string[],\n opts: LocalizeOptions,\n deps: Deps,\n): number {\n return forEachName(names, opts, deps, localizeOne);\n}\n\n/**\n * The loop `localize` and `adopt` share: read the manifest once, run `one` per\n * name, write the manifest after each, then assert the links and the\n * consumer's untouched manifests.\n *\n * @param {(name: string, dir: string, recorded: object|undefined, opts: object, deps: object)\n * => {code: number, entry?: {name: string, value: object}}} one\n */\nexport function forEachName(\n names: string[],\n opts: LocalizeOptions,\n deps: Deps,\n one: OneName,\n): number {\n // Taken BEFORE anything runs: the post-condition is about what THIS run\n // changed, not about what the tree looked like at HEAD.\n const before = snapshotManifests(deps.appRoot);\n\n let manifest;\n try {\n manifest = readManifest(deps.appRoot, deps);\n } catch (e) {\n return reportError(e, deps);\n }\n\n const dir = opts.dir ?? manifest.dir ?? DEFAULT_DIR;\n const entries = {...manifest.entries};\n let code = 0;\n let recorded = false;\n\n for (const name of names) {\n try {\n const result = one(name, dir, entries[name], opts, deps);\n if (result.entry) {\n entries[result.entry.name] = result.entry.value;\n recorded = true;\n }\n code = Math.max(code, result.code);\n // Written after EACH name, so an interruption keeps what already worked.\n writeManifest(deps.appRoot, {\n version: SCHEMA_VERSION,\n dir,\n packages: entries,\n });\n } catch (e) {\n code = Math.max(code, reportError(e, deps));\n }\n }\n\n // Over EVERY localized checkout, not just the ones named: localizing `B`\n // is what makes `A`'s registry copy of `B` redundant.\n if (shouldPrune(opts)) {\n try {\n pruneProvided(entries, opts, deps);\n } catch (e) {\n deps.warn(\n `[localize] pruning failed, the checkouts' node_modules are as npm left them: ${e.message}`,\n );\n code = Math.max(code, EXIT_WARNED);\n }\n }\n\n code = Math.max(code, assertLinked(entries, deps));\n code = Math.max(code, assertManifestsUntouched(before, deps));\n // After the assertion, so it still covers everything the work itself did.\n if (recorded) ensureRelinkHooksIn(deps);\n return code;\n}\n\n/** Add the relink hooks to the app's package.json when it lacks them. See relinkHooks.ts. */\nfunction ensureRelinkHooksIn(deps: Deps): void {\n const added = ensureRelinkHooksInFile(\n path.join(deps.appRoot, 'package.json'),\n );\n if (!added.length) return;\n deps.log(\n `[localize] Added \\`${RELINK_COMMAND}\\` to the app's ${added.join(' and ')} ` +\n `script${added.length > 1 ? 's' : ''} so npm keeps the links`,\n );\n}\n\nfunction localizeOne(\n name: string,\n dir: string,\n recorded: ManifestEntry | undefined,\n opts: LocalizeOptions,\n deps: Deps,\n): OneResult {\n // An override recorded by an earlier run is reused, so `--repo` is a\n // one-time cost rather than something to remember on every invocation.\n const override = opts.repo\n ? {repo: opts.repo, subdir: opts.subdir}\n : recorded?.repo && !looksLikeOrgSlug(recorded.repo)\n ? {repo: recorded.repo, subdir: recorded.subdir}\n : undefined;\n\n const resolved = resolveOrSuggestAdopt(name, dir, override, deps);\n let code = 0;\n\n const relClone = path.join(dir, resolved.checkoutName);\n const clone = path.join(deps.appRoot, relClone);\n // When the repository holds more than this package, the CHECKOUT is the\n // clone but the PACKAGE is a directory inside it: that is where the install\n // runs and that is what the symlink points at.\n const relPkg = resolved.subdir\n ? path.join(relClone, resolved.subdir)\n : relClone;\n const pkgDir = path.join(deps.appRoot, relPkg);\n\n guardForeignLink(resolved.npmName, dir, opts, deps);\n\n if (isGitCheckout(clone)) {\n code = Math.max(code, refresh(relClone, clone, deps));\n if (code === EXIT_WARNED) return {code}; // a non-fast-forward is reported, never forced\n } else {\n fs.mkdirSync(path.dirname(clone), {recursive: true});\n deps.log(`[localize] cloning ${resolved.repo} -> ${relClone}`);\n const r = deps.run('git', ['clone', resolved.repo, clone]);\n if (r.status !== 0) {\n throw new LocalizeError(\n `git clone ${resolved.repo} failed:\\n${(r.stderr || r.stdout).trim()}`,\n EXIT_REFUSED,\n );\n }\n }\n\n if (!fs.existsSync(path.join(pkgDir, 'package.json'))) {\n throw new LocalizeError(\n `${relPkg} has no package.json, so it is not the package \"${name}\".\\n` +\n (resolved.subdir\n ? `The registry says \"${name}\" lives in \"${resolved.subdir}\" of ${resolved.repo}, and it does not.`\n : `${resolved.repo} looks like a monorepo root. Say where the package lives:\\n` +\n ` linked localize ${name} --repo ${resolved.repo} --subdir <path-inside-the-repo>`),\n EXIT_REFUSED,\n );\n }\n\n // The checkout's own package.json is authoritative about the name: a\n // mismatch means the symlink would be written under a name nothing imports.\n const declared = readJson(path.join(pkgDir, 'package.json'))?.name;\n if (declared && declared !== resolved.npmName) {\n throw new LocalizeError(\n `${relPkg} declares itself as \"${declared}\", not \"${name}\".\\n` +\n (resolved.subdir\n ? `The registry's repository.directory for \"${name}\" points at the wrong package.`\n : `${resolved.repo} is probably a monorepo. Point at the right directory:\\n` +\n ` linked localize ${name} --repo ${resolved.repo} --subdir <path-inside-the-repo>`),\n EXIT_REFUSED,\n );\n }\n\n return installLinkAndRecord(\n {\n npmName: resolved.npmName,\n clone,\n relPkg,\n pkgDir,\n repo: resolved.repo,\n subdir: resolved.subdir,\n },\n opts,\n deps,\n code,\n );\n}\n\n/**\n * Everything after the checkout exists, shared by `localize` and `adopt`:\n * install inside it, run the configured build, link it, and describe the\n * manifest entry. Nothing here knows how the checkout got there.\n *\n * `repo` may be absent -- an adopted checkout with no remote is recorded\n * without one.\n */\nexport function installLinkAndRecord(\n {\n npmName,\n clone,\n relPkg,\n pkgDir,\n repo,\n subdir,\n }: {\n npmName: string;\n clone: string;\n relPkg: string;\n pkgDir: string;\n repo?: string;\n subdir?: string;\n },\n opts: LocalizeOptions,\n deps: Deps,\n code = 0,\n): {code: number; entry: {name: string; value: ManifestEntry}} {\n // THE constraint. Read the module header before changing this. `ensure`\n // installs inside the checkout and prunes it as one step (ensure.ts).\n try {\n code = Math.max(code, ensure({path: relPkg, subdir}, deps, opts));\n } catch (e) {\n if (e instanceof LocalizeError && e.code === EXIT_INSTALL_FAILED)\n e.message += `\\nThe checkout is left on disk. Nothing was linked and nothing was recorded.`;\n throw e;\n }\n\n // The build is the one thing localize does not know how to do, so it is\n // configuration rather than behaviour. A failure is a WARNING: a package\n // whose build is broken is exactly what you are about to fix, and refusing\n // to link it would be perverse.\n if (runBuild(relPkg, pkgDir, opts, deps) === 'failed')\n code = Math.max(code, EXIT_WARNED);\n\n writeLink(deps.appRoot, npmName, pkgDir);\n const branch = currentBranch(clone, deps);\n deps.log(`[localize] linked ${npmName} -> ${relPkg} (branch ${branch})`);\n\n const range = declaredRange(npmName, deps);\n return {\n code,\n entry: {\n name: npmName,\n value: {\n ...(repo ? {repo} : {}),\n path: relPkg,\n branch,\n ...(subdir ? {subdir} : {}),\n ...(range ? {range} : {}),\n // `--no-prune` is remembered, so the run-time check and `--relink` honour it too.\n ...(shouldPrune(opts) ? {} : {prune: false as const}),\n },\n },\n };\n}\n\n/**\n * A registry lookup that fails while a git checkout already sits where the\n * clone would go is almost always a package that was never published -- one\n * made locally. Say how to link it as it is rather than leave the developer\n * guessing at a `--repo`.\n */\nfunction resolveOrSuggestAdopt(name, dir, override, deps) {\n try {\n return resolvePackage(name, deps, override);\n } catch (e) {\n const relClone = path.join(dir, checkoutNameFor(name));\n if (\n e instanceof LocalizeError &&\n e.code === EXIT_NOT_FOUND &&\n isGitCheckout(path.join(deps.appRoot, relClone))\n ) {\n e.message +=\n `\\n${relClone} is already a git checkout. To link it as it is, with no registry lookup:\\n` +\n ` linked localize ${name} --adopt`;\n }\n throw e;\n }\n}\n\n/** Older manifests recorded `owner/repo`; those are re-resolved rather than cloned blind. */\nfunction looksLikeOrgSlug(repo) {\n return /^[\\w.-]+\\/[\\w.-]+$/.test(repo);\n}\n\n/**\n * Reuse an existing clone. A dirty tree is reused WITHOUT pulling and said so;\n * a clean one is fast-forwarded; a non-fast-forward is reported and skipped\n * rather than forced, because the developer's commits are the entire point.\n */\nfunction refresh(relPath, clone, deps) {\n const status = deps.run('git', ['status', '--porcelain'], {cwd: clone});\n const modified = status.stdout.split('\\n').filter((l) => l.trim()).length;\n if (modified > 0) {\n deps.log(\n `[localize] ${relPath}: ${modified} modified file${modified === 1 ? '' : 's'} — not pulling`,\n );\n return 0;\n }\n const pull = deps.run('git', ['pull', '--ff-only'], {cwd: clone});\n if (pull.status !== 0) {\n deps.warn(\n `[localize] ${relPath}: \\`git pull --ff-only\\` failed (not a fast-forward) — skipped, not ` +\n `forced. Reconcile it by hand:\\n${(pull.stderr || pull.stdout).trim()}`,\n );\n return EXIT_WARNED;\n }\n return 0;\n}\n\n/**\n * Run the configured build command, if there is one.\n *\n * localize has no opinion about how a checkout is built, and does not look for\n * a builder. `--build \"<cmd>\"`, or a `build` field in the manifest, or\n * `{build}` in the programmatic options. Absent -- the common case, and the\n * case for anything whose dev loop reads source directly -- nothing runs and\n * nothing is said.\n */\nfunction runBuild(relPath, pkgDir, opts, deps) {\n const cmd = opts.build;\n if (!cmd) return 'skipped';\n deps.log(`[localize] ${relPath}: ${cmd}`);\n const r = deps.run(cmd, [], {cwd: pkgDir, shell: true});\n if (r.status !== 0) {\n deps.warn(\n `[localize] ${relPath}: \\`${cmd}\\` failed. The package is linked and recorded anyway — ` +\n `a package whose build is broken is exactly what you are about to fix.\\n` +\n `${(r.stderr || r.stdout).trim()}`,\n );\n return 'failed';\n }\n return 'ok';\n}\n\n/** Refuse when `node_modules/<name>` is already a symlink pointing outside `<dir>`. */\nexport function guardForeignLink(\n npmName: string,\n dir: string,\n opts: {force?: boolean},\n deps: Deps,\n): void {\n const link = path.join(deps.appRoot, 'node_modules', npmName);\n if (!isSymlink(link)) return;\n let target;\n try {\n target = fs.realpathSync(link);\n } catch {\n return; // a dangling link is ours to replace\n }\n if (isInside(target, path.join(deps.appRoot, dir))) return;\n if (opts.force) {\n deps.warn(\n `[localize] --force: overwriting the existing link ${npmName} -> ${target}`,\n );\n return;\n }\n throw new LocalizeError(\n `node_modules/${npmName} is already a symlink to ${target}, which is outside ${dir}.\\n` +\n `Refusing to overwrite someone else's link. Pass --force to replace it.`,\n EXIT_REFUSED,\n );\n}\n\n/** Every recorded package is actually linked where the manifest says it is. */\nfunction assertLinked(entries: Record<string, ManifestEntry>, deps: Deps) {\n let code = 0;\n for (const [name, entry] of Object.entries(entries)) {\n const link = path.join(deps.appRoot, 'node_modules', name);\n const expected = path.join(deps.appRoot, entry.path);\n if (!isSymlink(link)) {\n deps.warn(\n `[localize] ${name} is recorded but node_modules/${name} is not a symlink.`,\n );\n code = Math.max(code, EXIT_WARNED);\n continue;\n }\n if (!fs.existsSync(expected)) continue; // \"checkout missing\" is a --list state, not a failure\n if (fs.realpathSync(link) !== fs.realpathSync(expected)) {\n deps.warn(\n `[localize] ${name} links to ${fs.realpathSync(link)} but the manifest records ${entry.path}.`,\n );\n code = Math.max(code, EXIT_WARNED);\n }\n }\n return code;\n}\n\n/**\n * The property the whole design rests on: this run changed neither manifest.\n *\n * Content hashes, not `git status`. `git status` compares against HEAD, so in\n * any tree with an uncommitted `package.json` it reports a modification the\n * command did not make -- an earlier tool shipped exactly that and reported\n * correct runs as failures.\n */\nexport function assertManifestsUntouched(\n before: Record<string, string | null>,\n deps: Deps,\n): number {\n const changed = diffManifests(before, snapshotManifests(deps.appRoot));\n if (!changed.length) return 0;\n deps.error(\n `[localize] the consumer's manifests changed while this command ran:\\n` +\n changed.map((c) => ` ${c}`).join('\\n') +\n `\\nThis is the exact failure localize exists to prevent. Revert those files; nothing in ` +\n `localize is supposed to touch them.`,\n );\n return EXIT_MANIFEST_DIRTY;\n}\n\nexport function reportError(e: unknown, deps: Pick<Deps, 'error'>): number {\n if (e instanceof LocalizeError) {\n deps.error(`[localize] ${e.message}`);\n return e.code;\n }\n throw e;\n}\n\n/**\n * The checked-out branch, or `HEAD` when detached. `symbolic-ref` first,\n * because it also names the branch of a repository with no commits yet --\n * `rev-parse --abbrev-ref` fails there, and `create-package` adopts a fresh\n * `git init` before its first commit.\n */\nexport function currentBranch(clone: string, deps: Deps): string {\n const sym = deps.run('git', ['symbolic-ref', '--short', '-q', 'HEAD'], {\n cwd: clone,\n });\n if (sym.status === 0 && sym.stdout.trim()) return sym.stdout.trim();\n const r = deps.run('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {\n cwd: clone,\n });\n const b = r.stdout.trim();\n return r.status === 0 && b ? b : 'HEAD';\n}\n\nexport function declaredRange(\n name: string,\n deps: Pick<Deps, 'appRoot'>,\n): string | undefined {\n const pkg = readJson(path.join(deps.appRoot, 'package.json'));\n if (!pkg) return undefined;\n return (\n pkg.dependencies?.[name] ??\n pkg.devDependencies?.[name] ??\n pkg.optionalDependencies?.[name]\n );\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import type { PackageKind } from './packageKind.js';
1
2
  export declare const PACKAGE_LOCATIONS: readonly ["packages", "packages-local"];
2
3
  export type PackageLocation = (typeof PACKAGE_LOCATIONS)[number];
3
4
  export interface CreatePackageOptions {
@@ -7,6 +8,18 @@ export interface CreatePackageOptions {
7
8
  remote?: string;
8
9
  /** Push the initial commit. Needs `remote`. */
9
10
  push?: boolean;
11
+ /**
12
+ * What to scaffold: an ontology package, an asset package or both. See
13
+ * `./packageKind.js`. Validated at runtime too.
14
+ */
15
+ kind?: PackageKind;
16
+ /** Write the files only: no install, no build, no git. */
17
+ skipInstall?: boolean;
18
+ /**
19
+ * The root the package's IRIs are minted under. Inside an app it defaults to the
20
+ * app's `LINKED_BASE_URI`; see `./packageBaseUri.js`.
21
+ */
22
+ baseUri?: string;
10
23
  }
11
24
  /**
12
25
  * - `outside`: no app above us — the old behaviour, unchanged.
@@ -60,12 +73,14 @@ export declare function ensureWorkspaceGlob(pkg: Record<string, any>): {
60
73
  changed: boolean;
61
74
  warning?: string;
62
75
  };
63
- export declare const RELINK_COMMAND = "linked localize --relink";
76
+ export { RELINK_COMMAND, ensureRelinkHooks } from './relinkHooks.js';
64
77
  /**
65
- * Make sure the app's `postinstall` recreates localize's links. Without it the
66
- * next `npm install` prunes a packages-local link as extraneous. With no
67
- * `local-packages.json` the hook prints nothing and exits 0, so it is safe to
68
- * commit for everyone. Mutates `pkg`.
78
+ * Make sure the app's `postinstall` AND `dependencies` scripts recreate
79
+ * localize's links -- see `./relinkHooks.js` for why npm needs both. Kept
80
+ * under its old name for existing callers; prefer `ensureRelinkHooks`.
81
+ * Mutates `pkg`.
82
+ *
83
+ * @returns true when it changed `pkg`.
69
84
  */
70
85
  export declare function ensureRelinkPostinstall(pkg: Record<string, any>): boolean;
71
86
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"createPackageLocation.d.ts","sourceRoot":"","sources":["../../../src/utils/createPackageLocation.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,iBAAiB,yCAA0C,CAAC;AACzE,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjE,MAAM,WAAW,oBAAoB;IACnC,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GACtB;IAAC,IAAI,EAAE,SAAS,CAAA;CAAC,GACjB;IAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,eAAe,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,C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