@_linked/cli 1.41.1 → 1.42.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.
- package/CHANGELOG.md +17 -0
- package/README.md +21 -54
- package/lib/esm/cli-methods.js +2 -2
- package/lib/esm/cli-methods.js.map +1 -1
- package/lib/esm/cli.js +13 -1
- package/lib/esm/cli.js.map +1 -1
- package/lib/esm/commands/localize.d.ts +6 -15
- package/lib/esm/commands/localize.d.ts.map +1 -1
- package/lib/esm/commands/localize.js +26 -35
- package/lib/esm/commands/localize.js.map +1 -1
- package/lib/esm/installed-packages.d.ts +12 -12
- package/lib/esm/installed-packages.d.ts.map +1 -1
- package/lib/esm/installed-packages.js +37 -27
- package/lib/esm/installed-packages.js.map +1 -1
- package/lib/esm/lifecycle.d.ts +4 -3
- package/lib/esm/lifecycle.d.ts.map +1 -1
- package/lib/esm/lifecycle.js +6 -14
- package/lib/esm/lifecycle.js.map +1 -1
- package/lib/esm/localize/adopt.d.ts +10 -0
- package/lib/esm/localize/adopt.d.ts.map +1 -0
- package/lib/esm/localize/adopt.js +76 -0
- package/lib/esm/localize/adopt.js.map +1 -0
- package/lib/esm/localize/delocalize.d.ts +6 -0
- package/lib/esm/localize/delocalize.d.ts.map +1 -0
- package/lib/esm/localize/delocalize.js +138 -0
- package/lib/esm/localize/delocalize.js.map +1 -0
- package/lib/esm/localize/ensure.d.ts +26 -0
- package/lib/esm/localize/ensure.d.ts.map +1 -0
- package/lib/esm/localize/ensure.js +152 -0
- package/lib/esm/localize/ensure.js.map +1 -0
- package/lib/esm/localize/errors.d.ts +23 -0
- package/lib/esm/localize/errors.d.ts.map +1 -0
- package/lib/esm/localize/errors.js +26 -0
- package/lib/esm/localize/errors.js.map +1 -0
- package/lib/esm/localize/fsops.d.ts +36 -0
- package/lib/esm/localize/fsops.d.ts.map +1 -0
- package/lib/esm/localize/fsops.js +155 -0
- package/lib/esm/localize/fsops.js.map +1 -0
- package/lib/esm/localize/index.d.ts +29 -0
- package/lib/esm/localize/index.d.ts.map +1 -0
- package/lib/esm/localize/index.js +22 -0
- package/lib/esm/localize/index.js.map +1 -0
- package/lib/esm/localize/list.d.ts +18 -0
- package/lib/esm/localize/list.d.ts.map +1 -0
- package/lib/esm/localize/list.js +174 -0
- package/lib/esm/localize/list.js.map +1 -0
- package/lib/esm/localize/localize.d.ts +84 -0
- package/lib/esm/localize/localize.d.ts.map +1 -0
- package/lib/esm/localize/localize.js +354 -0
- package/lib/esm/localize/localize.js.map +1 -0
- package/lib/esm/localize/manifest.d.ts +54 -0
- package/lib/esm/localize/manifest.d.ts.map +1 -0
- package/lib/esm/localize/manifest.js +133 -0
- package/lib/esm/localize/manifest.js.map +1 -0
- package/lib/esm/localize/provided.d.ts +28 -0
- package/lib/esm/localize/provided.d.ts.map +1 -0
- package/lib/esm/localize/provided.js +89 -0
- package/lib/esm/localize/provided.js.map +1 -0
- package/lib/esm/localize/prune.d.ts +58 -0
- package/lib/esm/localize/prune.d.ts.map +1 -0
- package/lib/esm/localize/prune.js +390 -0
- package/lib/esm/localize/prune.js.map +1 -0
- package/lib/esm/localize/relink.d.ts +11 -0
- package/lib/esm/localize/relink.d.ts.map +1 -0
- package/lib/esm/localize/relink.js +174 -0
- package/lib/esm/localize/relink.js.map +1 -0
- package/lib/esm/localize/resolve.d.ts +47 -0
- package/lib/esm/localize/resolve.d.ts.map +1 -0
- package/lib/esm/localize/resolve.js +153 -0
- package/lib/esm/localize/resolve.js.map +1 -0
- package/lib/esm/localize/run.d.ts +35 -0
- package/lib/esm/localize/run.d.ts.map +1 -0
- package/lib/esm/localize/run.js +30 -0
- package/lib/esm/localize/run.js.map +1 -0
- package/lib/esm/localized-dedupe.d.ts +6 -0
- package/lib/esm/localized-dedupe.d.ts.map +1 -1
- package/lib/esm/localized-dedupe.js +23 -66
- package/lib/esm/localized-dedupe.js.map +1 -1
- package/package.json +1 -2
package/lib/esm/cli.js
CHANGED
|
@@ -19,6 +19,7 @@ import fs from 'fs-extra';
|
|
|
19
19
|
import path from 'path';
|
|
20
20
|
import 'require-extensions';
|
|
21
21
|
import { unknownCommandError } from './unknown-command.js';
|
|
22
|
+
import { checkOneCopy } from './localize/ensure.js';
|
|
22
23
|
/**
|
|
23
24
|
* Run an async command action and report a failure the way the rest of this
|
|
24
25
|
* CLI does — one red message and exit code 1 — instead of letting the rejection
|
|
@@ -309,12 +310,14 @@ program
|
|
|
309
310
|
.option('--adopt', '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.')
|
|
310
311
|
.option('--check', 'With --list: exit 1 when something recorded is not actually linked.')
|
|
311
312
|
.option('--relink', 'Recreate the recorded symlinks. This is what a postinstall runs.')
|
|
313
|
+
.option('--ensure', "Remove every localized checkout's own copy of a package the app provides, and exit 0. 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).")
|
|
314
|
+
.option('--reinstall <package>', "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.")
|
|
312
315
|
.option('--dir <path>', 'Where checkouts live (default: packages-local).')
|
|
313
316
|
.option('--repo <git-url>', "Clone this instead of the published repository, and record it. With --adopt: record this instead of the checkout's origin.")
|
|
314
317
|
.option('--subdir <path>', "The package's directory inside the repository (monorepos).")
|
|
315
318
|
.option('--build <cmd>', 'Run this in the checkout after installing; a failure only warns. Defaults to `linked build`; pass an empty string to build nothing.')
|
|
316
319
|
.option('--force', 'Overwrite a symlink pointing outside the checkout directory.')
|
|
317
|
-
.option('--no-prune', "Keep every checkout's node_modules as npm installed it. By default, after installing (and on --relink) a checkout's own copy of
|
|
320
|
+
.option('--no-prune', "Keep every checkout's node_modules as npm installed it. By default, after installing (and on --relink and --reinstall) a checkout's own copy of something the app provides is removed: a localized sibling, a runtime dependency of a localized checkout that the app has at a version satisfying every localized range, react or react-dom. The checkout then loads the app's copy instead of a second one. A copy the app's version does not satisfy is kept, with a warning.")
|
|
318
321
|
.action((packages, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
319
322
|
const { runLocalize } = yield import('./commands/localize.js');
|
|
320
323
|
return runLocalize(packages, options);
|
|
@@ -411,6 +414,15 @@ program
|
|
|
411
414
|
program.command('enable-capacitor').action(() => {
|
|
412
415
|
addCapacitor();
|
|
413
416
|
});
|
|
417
|
+
// One copy, always (localize/ensure.ts): before a command that runs the app's
|
|
418
|
+
// code, remove any localized checkout's own copy of what the app provides.
|
|
419
|
+
// Stat-only, never runs npm, silent when clean, a no-op with no
|
|
420
|
+
// local-packages.json, and it never throws.
|
|
421
|
+
const ONE_COPY_COMMANDS = new Set(['start', 'script', 'call', 'build-all']);
|
|
422
|
+
program.hook('preAction', (_program, actionCommand) => {
|
|
423
|
+
if (ONE_COPY_COMMANDS.has(actionCommand.name()))
|
|
424
|
+
checkOneCopy(process.cwd());
|
|
425
|
+
});
|
|
414
426
|
const unknownCommand = unknownCommandError(program, process.argv.slice(2));
|
|
415
427
|
if (unknownCommand) {
|
|
416
428
|
console.error(chalk.red(unknownCommand));
|
package/lib/esm/cli.js.map
CHANGED
|
@@ -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,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C;AAEH,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} 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';\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('--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 every checkout's node_modules as npm installed it. By default, after installing (and on --relink) a checkout's own copy of a linked package (one with linkedPackage: true in its package.json), react or react-dom is removed when the app has a version that satisfies the checkout's range, so the checkout loads the app's copy (and a localized sibling) instead of a second one. A copy the app's version does not satisfy is kept, with a warning.\",\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\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,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,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAElD;;;;GAIG;AACH,MAAM,aAAa,GAAG,CAAO,GAA2B,EAAiB,EAAE;IACzE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E;IACpD,IAAI,iBAAiB,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;QAAE,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AAC/E,CAAC,CAAC,CAAC;AAEH,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} 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 {checkOneCopy} from './localize/ensure.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, and exit 0. 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 every checkout's node_modules as npm installed it. By default, after installing (and on --relink and --reinstall) a checkout's own copy of something the app provides is removed: a localized sibling, a runtime dependency of a localized checkout that the app has at a version satisfying every localized range, react or react-dom. The checkout then loads the app's copy instead of a second one. A copy the app's version does not satisfy is kept, with a warning.\",\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.\n// Stat-only, never runs npm, silent when clean, a no-op with no\n// local-packages.json, and it never throws.\nconst ONE_COPY_COMMANDS = new Set(['start', 'script', 'call', 'build-all']);\nprogram.hook('preAction', (_program, actionCommand) => {\n if (ONE_COPY_COMMANDS.has(actionCommand.name())) checkOneCopy(process.cwd());\n});\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,22 +1,14 @@
|
|
|
1
1
|
/** The build command `localize` runs inside a fresh checkout by default. */
|
|
2
2
|
export declare const DEFAULT_BUILD_COMMAND = "linked build";
|
|
3
|
-
/**
|
|
4
|
-
* What a linked app provides to its localized checkouts: the names of the
|
|
5
|
-
* linked packages it has installed — by their `linkedPackage` flag, whatever
|
|
6
|
-
* their scope — plus `react` and `react-dom`. Each one either holds
|
|
7
|
-
* module-level state that must exist once (core's shape registry, React's
|
|
8
|
-
* dispatcher, the context objects in server-utils and react) or is a localized
|
|
9
|
-
* sibling the checkout should reach live (see `appProvidedPackages`). localize
|
|
10
|
-
* itself already treats every localized sibling and a checkout's
|
|
11
|
-
* peerDependencies as provided. Vite's `resolve.dedupe` is derived separately,
|
|
12
|
-
* from what is localized (`localized-dedupe.ts`).
|
|
13
|
-
*/
|
|
14
|
-
export declare function providedByApp(appRoot: string): Promise<string[]>;
|
|
15
3
|
export interface LocalizeCommandOptions {
|
|
16
4
|
adopt?: boolean;
|
|
17
5
|
list?: boolean;
|
|
18
6
|
check?: boolean;
|
|
19
7
|
relink?: boolean;
|
|
8
|
+
/** Check every checkout for a copy of what the app provides and prune it; exit 0. */
|
|
9
|
+
ensure?: boolean;
|
|
10
|
+
/** `npm install` in this package's checkout, then prune it. */
|
|
11
|
+
reinstall?: string;
|
|
20
12
|
dir?: string;
|
|
21
13
|
repo?: string;
|
|
22
14
|
subdir?: string;
|
|
@@ -27,10 +19,9 @@ export interface LocalizeCommandOptions {
|
|
|
27
19
|
prune?: boolean;
|
|
28
20
|
}
|
|
29
21
|
/** localize's prune options for a run: on unless explicitly turned off. */
|
|
30
|
-
export declare function pruneOptions(
|
|
22
|
+
export declare function pruneOptions(prune?: boolean | undefined): {
|
|
31
23
|
prune: boolean;
|
|
32
|
-
|
|
33
|
-
}>;
|
|
24
|
+
};
|
|
34
25
|
/**
|
|
35
26
|
* `localize` reports failure through an exit code rather than by throwing, so
|
|
36
27
|
* that a partial run still prints what it did. Mirror that: set `exitCode` and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localize.d.ts","sourceRoot":"","sources":["../../../src/commands/localize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"localize.d.ts","sourceRoot":"","sources":["../../../src/commands/localize.ts"],"names":[],"mappings":"AAiDA,4EAA4E;AAC5E,eAAO,MAAM,qBAAqB,iB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this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
* `linked localize` / `linked delocalize` — develop an npm dependency from a
|
|
12
12
|
* git checkout.
|
|
13
13
|
*
|
|
14
|
-
* All of the work lives in
|
|
15
|
-
* knows nothing about this framework on
|
|
16
|
-
* repository from the registry, clones it,
|
|
17
|
-
* symlinks it into `node_modules`, without
|
|
18
|
-
* `package-lock.json`.
|
|
14
|
+
* All of the work lives in `../localize/` (once the separate
|
|
15
|
+
* `@_linked/localize` package), which knows nothing about this framework on
|
|
16
|
+
* purpose: it resolves a package's repository from the registry, clones it,
|
|
17
|
+
* installs inside the checkout and symlinks it into `node_modules`, without
|
|
18
|
+
* touching `package.json` or `package-lock.json`. This module is the commander
|
|
19
|
+
* adapter over it.
|
|
19
20
|
*
|
|
20
21
|
* The one thing it deliberately does not know is how to build what it cloned.
|
|
21
22
|
* That is the seam this module fills: `@_linked/cli` passes `build: 'linked
|
|
@@ -28,13 +29,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
28
29
|
* from the registry's `repository` field, so a name that npm cannot resolve is
|
|
29
30
|
* an error rather than a guess.
|
|
30
31
|
*
|
|
31
|
-
*
|
|
32
|
-
* checkout's own install leaves its own copies of `@_linked/core`, React and
|
|
32
|
+
* A checkout's own install leaves its own copies of `@_linked/core`, React and
|
|
33
33
|
* any localized sibling in its `node_modules`, and Node loads those instead of
|
|
34
34
|
* the app's: a localized package then never sees a localized sibling, and core
|
|
35
35
|
* loads once per copy. localize removes those copies by default wherever the
|
|
36
|
-
* app's version satisfies the checkout's
|
|
37
|
-
*
|
|
36
|
+
* app's version satisfies the checkout's ranges (`--no-prune` turns it off).
|
|
37
|
+
* What the app provides is one rule, `providedPackages` (localize/provided.ts),
|
|
38
|
+
* shared with the run-time check (`--ensure`, and before `linked start` etc.)
|
|
39
|
+
* and Vite's dedupe.
|
|
38
40
|
*
|
|
39
41
|
* `--adopt` is the exception to "clone from the registry": it links a git
|
|
40
42
|
* checkout that is already in `packages-local/` under its localize name, with
|
|
@@ -42,30 +44,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
42
44
|
* hand. It takes no `--subdir`: an adopted checkout is the package itself.
|
|
43
45
|
*/
|
|
44
46
|
import process from 'node:process';
|
|
47
|
+
import { adopt, checkOneCopy, defaultDeps, delocalize, list, localize, reinstall, relink, } from '../localize/index.js';
|
|
45
48
|
/** The build command `localize` runs inside a fresh checkout by default. */
|
|
46
49
|
export const DEFAULT_BUILD_COMMAND = 'linked build';
|
|
47
|
-
/**
|
|
48
|
-
* What a linked app provides to its localized checkouts: the names of the
|
|
49
|
-
* linked packages it has installed — by their `linkedPackage` flag, whatever
|
|
50
|
-
* their scope — plus `react` and `react-dom`. Each one either holds
|
|
51
|
-
* module-level state that must exist once (core's shape registry, React's
|
|
52
|
-
* dispatcher, the context objects in server-utils and react) or is a localized
|
|
53
|
-
* sibling the checkout should reach live (see `appProvidedPackages`). localize
|
|
54
|
-
* itself already treats every localized sibling and a checkout's
|
|
55
|
-
* peerDependencies as provided. Vite's `resolve.dedupe` is derived separately,
|
|
56
|
-
* from what is localized (`localized-dedupe.ts`).
|
|
57
|
-
*/
|
|
58
|
-
export function providedByApp(appRoot) {
|
|
59
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
const { appProvidedPackages } = yield import('../installed-packages.js');
|
|
61
|
-
return appProvidedPackages(appRoot);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
50
|
/** localize's prune options for a run: on unless explicitly turned off. */
|
|
65
|
-
export function pruneOptions(
|
|
66
|
-
return
|
|
67
|
-
return { prune: prune !== false, provided: yield providedByApp(appRoot) };
|
|
68
|
-
});
|
|
51
|
+
export function pruneOptions(prune = true) {
|
|
52
|
+
return { prune: prune !== false };
|
|
69
53
|
}
|
|
70
54
|
/**
|
|
71
55
|
* `localize` reports failure through an exit code rather than by throwing, so
|
|
@@ -74,13 +58,22 @@ export function pruneOptions(appRoot_1) {
|
|
|
74
58
|
*/
|
|
75
59
|
export function runLocalize() {
|
|
76
60
|
return __awaiter(this, arguments, void 0, function* (packages = [], options = {}) {
|
|
77
|
-
const { defaultDeps, localize, adopt, list, relink } = yield import('@_linked/localize');
|
|
78
61
|
const deps = defaultDeps(process.cwd());
|
|
79
|
-
const prune =
|
|
62
|
+
const prune = pruneOptions(options.prune);
|
|
80
63
|
if (options.relink) {
|
|
81
64
|
process.exitCode = relink(deps, prune);
|
|
82
65
|
return;
|
|
83
66
|
}
|
|
67
|
+
if (options.ensure) {
|
|
68
|
+
// For an app's npm `pre*` scripts: never fails the script it guards.
|
|
69
|
+
checkOneCopy(deps.appRoot, deps);
|
|
70
|
+
process.exitCode = 0;
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (options.reinstall) {
|
|
74
|
+
process.exitCode = reinstall(options.reinstall, prune, deps);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
84
77
|
if (options.adopt && packages.length === 0) {
|
|
85
78
|
console.error('[localize] --adopt needs at least one package name.');
|
|
86
79
|
process.exitCode = 2;
|
|
@@ -114,16 +107,14 @@ export function runLocalize() {
|
|
|
114
107
|
*/
|
|
115
108
|
export function adoptPackage(name, options) {
|
|
116
109
|
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
-
const { defaultDeps, adopt } = yield import('@_linked/localize');
|
|
118
110
|
// Exit codes are localize's public contract; EXIT_WARNED (5) is the one a
|
|
119
111
|
// caller usually tolerates, meaning the build failed but the link is in place.
|
|
120
|
-
return adopt([name], Object.assign({ build: options.build, repo: options.repo },
|
|
112
|
+
return adopt([name], Object.assign({ build: options.build, repo: options.repo }, pruneOptions()), defaultDeps(options.appRoot));
|
|
121
113
|
});
|
|
122
114
|
}
|
|
123
115
|
/** `linked delocalize [packages...]` — unlink and forget; no names means all. */
|
|
124
116
|
export function runDelocalize() {
|
|
125
117
|
return __awaiter(this, arguments, void 0, function* (packages = [], options = {}) {
|
|
126
|
-
const { defaultDeps, delocalize } = yield import('@_linked/localize');
|
|
127
118
|
const deps = defaultDeps(process.cwd());
|
|
128
119
|
process.exitCode = delocalize(packages, { purge: options.purge, force: options.force }, deps);
|
|
129
120
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localize.js","sourceRoot":"","sources":["../../../src/commands/localize.ts"],"names":[],"mappings":";;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"localize.js","sourceRoot":"","sources":["../../../src/commands/localize.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EACL,KAAK,EACL,YAAY,EACZ,WAAW,EACX,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,MAAM,GACP,MAAM,sBAAsB,CAAC;AAE9B,4EAA4E;AAC5E,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CAAC;AAqBpD,2EAA2E;AAC3E,MAAM,UAAU,YAAY,CAAC,QAA6B,IAAI;IAG5D,OAAO,EAAC,KAAK,EAAE,KAAK,KAAK,KAAK,EAAC,CAAC;AAClC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAgB,WAAW;yDAC/B,WAAqB,EAAE,EACvB,UAAkC,EAAE;QAEpC,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACxC,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAE1C,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YACvC,OAAO;QACT,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,qEAAqE;YACrE,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACjC,O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AQ,GAAG,QAAQ,CACzB,QAAQ,kBAEN,KAAK,EAAE,OAAO,CAAC,KAAK,EACpB,GAAG,EAAE,OAAO,CAAC,GAAG,EAChB,IAAI,EAAE,OAAO,CAAC,IAAI,EAClB,MAAM,EAAE,OAAO,CAAC,MAAM,EACtB,KAAK,IACF,KAAK,GAEV,IAAI,CACL,CAAC;IACJ,CAAC;CAAA;AAED;;;;;;;GAOG;AACH,MAAM,UAAgB,YAAY,CAChC,IAAY,EACZ,OAAwD;;QAExD,0EAA0E;QAC1E,+EAA+E;QAC/E,OAAO,KAAK,CACV,CAAC,IAAI,CAAC,kBAEJ,KAAK,EAAE,OAAO,CAAC,KAAK,EACpB,IAAI,EAAE,OAAO,CAAC,IAAI,IACf,YAAY,EAAE,GAEnB,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAC7B,CAAC;IACJ,CAAC;CAAA;AAED,iFAAiF;AACjF,MAAM,UAAgB,aAAa;yDACjC,WAAqB,EAAE,EACvB,UAA2D,EAAE;QAE7D,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACxC,OAAO,CAAC,QAAQ,GAAG,UAAU,CAC3B,QAAQ,EACR,EAAC,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAC,EAC5C,IAAI,CACL,CAAC;IACJ,CAAC;CAAA","sourcesContent":["/**\n * `linked localize` / `linked delocalize` — develop an npm dependency from a\n * git checkout.\n *\n * All of the work lives in `../localize/` (once the separate\n * `@_linked/localize` package), which knows nothing about this framework on\n * purpose: it resolves a package's repository from the registry, clones it,\n * installs inside the checkout and symlinks it into `node_modules`, without\n * touching `package.json` or `package-lock.json`. This module is the commander\n * adapter over it.\n *\n * The one thing it deliberately does not know is how to build what it cloned.\n * That is the seam this module fills: `@_linked/cli` passes `build: 'linked\n * build'`, because in this ecosystem that is what building a package means.\n * A failing build only warns — a package whose build is broken is usually\n * exactly what you localized it to fix.\n *\n * Packages are named exactly as npm names them (`@_linked/rdfs`, `lodash`).\n * There is no short-name expansion and no org probing: the repository comes\n * from the registry's `repository` field, so a name that npm cannot resolve is\n * an error rather than a guess.\n *\n * A checkout's own install leaves its own copies of `@_linked/core`, React and\n * any localized sibling in its `node_modules`, and Node loads those instead of\n * the app's: a localized package then never sees a localized sibling, and core\n * loads once per copy. localize removes those copies by default wherever the\n * app's version satisfies the checkout's ranges (`--no-prune` turns it off).\n * What the app provides is one rule, `providedPackages` (localize/provided.ts),\n * shared with the run-time check (`--ensure`, and before `linked start` etc.)\n * and Vite's dedupe.\n *\n * `--adopt` is the exception to \"clone from the registry\": it links a git\n * checkout that is already in `packages-local/` under its localize name, with\n * no clone and no lookup — a package created locally, or a clone put there by\n * hand. It takes no `--subdir`: an adopted checkout is the package itself.\n */\nimport process from 'node:process';\n\nimport {\n adopt,\n checkOneCopy,\n defaultDeps,\n delocalize,\n list,\n localize,\n reinstall,\n relink,\n} from '../localize/index.js';\n\n/** The build command `localize` runs inside a fresh checkout by default. */\nexport const DEFAULT_BUILD_COMMAND = 'linked build';\n\nexport interface LocalizeCommandOptions {\n adopt?: boolean;\n list?: boolean;\n check?: boolean;\n relink?: boolean;\n /** Check every checkout for a copy of what the app provides and prune it; exit 0. */\n ensure?: boolean;\n /** `npm install` in this package's checkout, then prune it. */\n reinstall?: string;\n dir?: string;\n repo?: string;\n subdir?: string;\n build?: string;\n force?: boolean;\n purge?: boolean;\n /** Commander's `--no-prune` sets this to false; absent means on. */\n prune?: boolean;\n}\n\n/** localize's prune options for a run: on unless explicitly turned off. */\nexport function pruneOptions(prune: boolean | undefined = true): {\n prune: boolean;\n} {\n return {prune: prune !== false};\n}\n\n/**\n * `localize` reports failure through an exit code rather than by throwing, so\n * that a partial run still prints what it did. Mirror that: set `exitCode` and\n * return, instead of exiting, so pending output is flushed.\n */\nexport async function runLocalize(\n packages: string[] = [],\n options: LocalizeCommandOptions = {},\n): Promise<void> {\n const deps = defaultDeps(process.cwd());\n const prune = pruneOptions(options.prune);\n\n if (options.relink) {\n process.exitCode = relink(deps, prune);\n return;\n }\n if (options.ensure) {\n // For an app's npm `pre*` scripts: never fails the script it guards.\n checkOneCopy(deps.appRoot, deps);\n process.exitCode = 0;\n return;\n }\n if (options.reinstall) {\n process.exitCode = reinstall(options.reinstall, prune, deps);\n return;\n }\n if (options.adopt && packages.length === 0) {\n console.error('[localize] --adopt needs at least one package name.');\n process.exitCode = 2;\n return;\n }\n if (options.adopt && options.subdir) {\n console.error(\n '[localize] --adopt takes no --subdir: an adopted checkout is the package itself.',\n );\n process.exitCode = 2;\n return;\n }\n if (options.list || packages.length === 0) {\n process.exitCode = list({check: options.check}, deps);\n return;\n }\n // `--build ''` is how you ask for no build at all.\n const build =\n options.build === undefined ? DEFAULT_BUILD_COMMAND : options.build;\n if (options.adopt) {\n process.exitCode = adopt(\n packages,\n {\n force: options.force,\n dir: options.dir,\n repo: options.repo,\n build,\n ...prune,\n },\n deps,\n );\n return;\n }\n process.exitCode = localize(\n packages,\n {\n force: options.force,\n dir: options.dir,\n repo: options.repo,\n subdir: options.subdir,\n build,\n ...prune,\n },\n deps,\n );\n}\n\n/**\n * Adopt one checkout that already sits in `packages-local/` under its localize\n * name: install inside it, build it, link it and record it. This is how\n * `create-package` hands a new package with its own repository to localize.\n *\n * @returns localize's exit code, rather than setting `process.exitCode`, so the\n * caller decides what a failure means.\n */\nexport async function adoptPackage(\n name: string,\n options: {appRoot: string; build: string; repo?: string},\n): Promise<number> {\n // Exit codes are localize's public contract; EXIT_WARNED (5) is the one a\n // caller usually tolerates, meaning the build failed but the link is in place.\n return adopt(\n [name],\n {\n build: options.build,\n repo: options.repo,\n ...pruneOptions(),\n },\n defaultDeps(options.appRoot),\n );\n}\n\n/** `linked delocalize [packages...]` — unlink and forget; no names means all. */\nexport async function runDelocalize(\n packages: string[] = [],\n options: Pick<LocalizeCommandOptions, 'purge' | 'force'> = {},\n): Promise<void> {\n const deps = defaultDeps(process.cwd());\n process.exitCode = delocalize(\n packages,\n {purge: options.purge, force: options.force},\n deps,\n );\n}\n"]}
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* A NAME check, used only by `client-dep-includes` (alongside the flag). Deciding
|
|
8
8
|
* whether an installed package is linked goes by its `package.json` instead —
|
|
9
|
-
* {@link isLinkedPackageJson} — which is what the source walk
|
|
10
|
-
* `optimizeDeps.exclude`
|
|
9
|
+
* {@link isLinkedPackageJson} — which is what the source walk and the standalone
|
|
10
|
+
* `optimizeDeps.exclude` use.
|
|
11
11
|
*/
|
|
12
12
|
export declare const FRAMEWORK_PKG_PATTERNS: RegExp[];
|
|
13
13
|
export declare const isFrameworkPkg: (name: string) => boolean;
|
|
@@ -16,11 +16,20 @@ export declare function readInstalledPkg(name: string, fromDir: string): Promise
|
|
|
16
16
|
root: string;
|
|
17
17
|
json: any;
|
|
18
18
|
} | null>;
|
|
19
|
+
/**
|
|
20
|
+
* {@link readInstalledPkg}, synchronously, for callers on a hot path that must
|
|
21
|
+
* not go async (the one-copy check before every `linked start`). Same walk,
|
|
22
|
+
* same stop at the workspace root.
|
|
23
|
+
*/
|
|
24
|
+
export declare function readInstalledPkgSync(name: string, fromDir: string): {
|
|
25
|
+
root: string;
|
|
26
|
+
json: any;
|
|
27
|
+
} | null;
|
|
19
28
|
/**
|
|
20
29
|
* THE definition of a linked package: its own `package.json` says
|
|
21
30
|
* `"linkedPackage": true`. Not its npm scope — a linked package can be
|
|
22
31
|
* published under any scope, and not everything under `@_linked/` is one
|
|
23
|
-
* (
|
|
32
|
+
* (a plain tool need not be). The pre-rename `"lincd": true` is not
|
|
24
33
|
* read: the packages that still carry it are the old `lincd-*` framework,
|
|
25
34
|
* which cannot share a runtime with `@_linked/core`. `lifecycle.ts`
|
|
26
35
|
* (`build-all`, `getLincdPackages`) and `linked build-package` use this too.
|
|
@@ -46,13 +55,4 @@ export interface InstalledLinkedPackage {
|
|
|
46
55
|
* it. The same name can therefore appear more than once, once per copy.
|
|
47
56
|
*/
|
|
48
57
|
export declare function discoverInstalledLinkedPackages(cwd?: string): Promise<InstalledLinkedPackage[]>;
|
|
49
|
-
/**
|
|
50
|
-
* The names of the linked packages an app itself provides: those
|
|
51
|
-
* {@link discoverInstalledLinkedPackages} finds that resolve from the app root
|
|
52
|
-
* (not only from inside some dependency's own `node_modules`), plus `react` and
|
|
53
|
-
* `react-dom` when they do. These are what must load once per runtime: what
|
|
54
|
-
* `linked localize` tells localize the app provides, so a checkout's own copy of
|
|
55
|
-
* one is removed.
|
|
56
|
-
*/
|
|
57
|
-
export declare function appProvidedPackages(cwd?: string): Promise<string[]>;
|
|
58
58
|
//# sourceMappingURL=installed-packages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installed-packages.d.ts","sourceRoot":"","sources":["../../src/installed-packages.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"installed-packages.d.ts","sourceRoot":"","sources":["../../src/installed-packages.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,EAA+B,CAAC;AAC3E,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,OACM,CAAC;AAUrD,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnE;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAC,GAAG,IAAI,CAAC,CAgB3C;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAC,GAAG,IAAI,CAgBlC;AAWD;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,GAAG,KAAG,OAClB,CAAC;AAE/B,wFAAwF;AACxF,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,GAAG,CAAC;CACX;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,+BAA+B,CACnD,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,sBAAsB,EAAE,CAAC,CA+BnC"}
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
// Locating installed packages the way Node does, shared by the Vite config
|
|
11
11
|
// helper and `linked app-doctor`.
|
|
12
12
|
import fsExtra from 'fs-extra';
|
|
13
|
+
import fs from 'node:fs';
|
|
13
14
|
import path from 'node:path';
|
|
14
15
|
/**
|
|
15
16
|
* Framework packages that MUST be single-instance per runtime — they hold
|
|
@@ -19,8 +20,8 @@ import path from 'node:path';
|
|
|
19
20
|
*
|
|
20
21
|
* A NAME check, used only by `client-dep-includes` (alongside the flag). Deciding
|
|
21
22
|
* whether an installed package is linked goes by its `package.json` instead —
|
|
22
|
-
* {@link isLinkedPackageJson} — which is what the source walk
|
|
23
|
-
* `optimizeDeps.exclude`
|
|
23
|
+
* {@link isLinkedPackageJson} — which is what the source walk and the standalone
|
|
24
|
+
* `optimizeDeps.exclude` use.
|
|
24
25
|
*/
|
|
25
26
|
export const FRAMEWORK_PKG_PATTERNS = [/^@_linked\//, /^lincd-/];
|
|
26
27
|
export const isFrameworkPkg = (name) => FRAMEWORK_PKG_PATTERNS.some((re) => re.test(name));
|
|
@@ -64,11 +65,44 @@ export function readInstalledPkg(name, fromDir) {
|
|
|
64
65
|
}
|
|
65
66
|
});
|
|
66
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* {@link readInstalledPkg}, synchronously, for callers on a hot path that must
|
|
70
|
+
* not go async (the one-copy check before every `linked start`). Same walk,
|
|
71
|
+
* same stop at the workspace root.
|
|
72
|
+
*/
|
|
73
|
+
export function readInstalledPkgSync(name, fromDir) {
|
|
74
|
+
let dir = path.resolve(fromDir);
|
|
75
|
+
while (true) {
|
|
76
|
+
const root = path.join(dir, 'node_modules', name);
|
|
77
|
+
const pkgJson = path.join(root, 'package.json');
|
|
78
|
+
if (fs.existsSync(pkgJson)) {
|
|
79
|
+
try {
|
|
80
|
+
return { root, json: JSON.parse(fs.readFileSync(pkgJson, 'utf8')) };
|
|
81
|
+
}
|
|
82
|
+
catch (_a) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const parent = path.dirname(dir);
|
|
87
|
+
if (parent === dir || isWorkspaceRootSync(dir))
|
|
88
|
+
return null;
|
|
89
|
+
dir = parent;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function isWorkspaceRootSync(dir) {
|
|
93
|
+
try {
|
|
94
|
+
return !!JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8'))
|
|
95
|
+
.workspaces;
|
|
96
|
+
}
|
|
97
|
+
catch (_a) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
67
101
|
/**
|
|
68
102
|
* THE definition of a linked package: its own `package.json` says
|
|
69
103
|
* `"linkedPackage": true`. Not its npm scope — a linked package can be
|
|
70
104
|
* published under any scope, and not everything under `@_linked/` is one
|
|
71
|
-
* (
|
|
105
|
+
* (a plain tool need not be). The pre-rename `"lincd": true` is not
|
|
72
106
|
* read: the packages that still carry it are the old `lincd-*` framework,
|
|
73
107
|
* which cannot share a runtime with `@_linked/core`. `lifecycle.ts`
|
|
74
108
|
* (`build-all`, `getLincdPackages`) and `linked build-package` use this too.
|
|
@@ -124,28 +158,4 @@ export function discoverInstalledLinkedPackages() {
|
|
|
124
158
|
return out;
|
|
125
159
|
});
|
|
126
160
|
}
|
|
127
|
-
/**
|
|
128
|
-
* The names of the linked packages an app itself provides: those
|
|
129
|
-
* {@link discoverInstalledLinkedPackages} finds that resolve from the app root
|
|
130
|
-
* (not only from inside some dependency's own `node_modules`), plus `react` and
|
|
131
|
-
* `react-dom` when they do. These are what must load once per runtime: what
|
|
132
|
-
* `linked localize` tells localize the app provides, so a checkout's own copy of
|
|
133
|
-
* one is removed.
|
|
134
|
-
*/
|
|
135
|
-
export function appProvidedPackages() {
|
|
136
|
-
return __awaiter(this, arguments, void 0, function* (cwd = process.cwd()) {
|
|
137
|
-
const names = new Set();
|
|
138
|
-
for (const pkg of yield discoverInstalledLinkedPackages(cwd)) {
|
|
139
|
-
if (names.has(pkg.name))
|
|
140
|
-
continue;
|
|
141
|
-
if (yield readInstalledPkg(pkg.name, cwd))
|
|
142
|
-
names.add(pkg.name);
|
|
143
|
-
}
|
|
144
|
-
for (const name of ['react', 'react-dom']) {
|
|
145
|
-
if (yield readInstalledPkg(name, cwd))
|
|
146
|
-
names.add(name);
|
|
147
|
-
}
|
|
148
|
-
return [...names].sort();
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
161
|
//# sourceMappingURL=installed-packages.js.map
|