@motujs/cli 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/bundled/github/agents/archipelago-build.agent.md +298 -0
- package/bundled/github/agents/island-create.agent.md +261 -0
- package/bundled/github/agents/island-extract.agent.md +360 -0
- package/bundled/github/agents/island-locate.agent.md +208 -0
- package/bundled/github/agents/motu-checks.agent.md +158 -0
- package/bundled/github/agents/motu-evidence.agent.md +267 -0
- package/bundled/github/agents/motu-regions.agent.md +304 -0
- package/bundled/github/host-rules.md +43 -0
- package/bundled/github/prompts/archipelago-build.prompt.md +19 -0
- package/bundled/github/prompts/island-create.prompt.md +37 -0
- package/bundled/github/prompts/island-extract.prompt.md +59 -0
- package/bundled/github/prompts/island-locate.prompt.md +43 -0
- package/bundled/packages/adapters/angularjs/vite.mjs +43 -0
- package/bundled/packages/adapters/next/lagoon/next-stubs.tsx +108 -0
- package/bundled/packages/adapters/next/vite.mjs +121 -0
- package/bundled/packages/adapters/vite/vite.mjs +179 -0
- package/package.json +64 -3
- package/src/alias-loader.mjs +63 -0
- package/src/alias-register.mjs +28 -0
- package/src/asset-stub.cjs +3 -0
- package/src/asset-stub.mjs +5 -0
- package/src/cli.mjs +78 -0
- package/src/commands/adopt-root.mjs +194 -0
- package/src/commands/archipelago-init.mjs +314 -0
- package/src/commands/archipelago.mjs +138 -0
- package/src/commands/assurance.mjs +40 -0
- package/src/commands/check.mjs +346 -0
- package/src/commands/codegen.mjs +29 -0
- package/src/commands/coverage.mjs +358 -0
- package/src/commands/create.mjs +277 -0
- package/src/commands/defaults.mjs +129 -0
- package/src/commands/diff.mjs +595 -0
- package/src/commands/fixtures.mjs +153 -0
- package/src/commands/init.mjs +473 -0
- package/src/commands/integrate.mjs +208 -0
- package/src/commands/integration.mjs +1349 -0
- package/src/commands/lagoon-try.mjs +272 -0
- package/src/commands/lagoon.mjs +1419 -0
- package/src/commands/link.mjs +110 -0
- package/src/commands/region-coverage.mjs +604 -0
- package/src/commands/removal-check.mjs +878 -0
- package/src/commands/skills.mjs +156 -0
- package/src/commands/snapshot.mjs +456 -0
- package/src/commands/sync.mjs +38 -0
- package/src/commands/verify/island-runtime.mjs +581 -0
- package/src/commands/verify/island-static.mjs +586 -0
- package/src/commands/verify/island.mjs +135 -0
- package/src/commands/verify/reach.mjs +426 -0
- package/src/commands/verify/region-composition.mjs +391 -0
- package/src/commands/verify/region-config.mjs +330 -0
- package/src/commands/verify/region-flows.mjs +760 -0
- package/src/commands/verify/region-sources.mjs +516 -0
- package/src/commands/verify/region.mjs +271 -0
- package/src/commands/verify/report.mjs +338 -0
- package/src/commands/verify/screens-runtime.mjs +123 -0
- package/src/commands/verify.mjs +18 -0
- package/src/lagoon-build.mjs +25 -0
- package/src/lagoon-dev.mjs +32 -0
- package/src/lib/alias-core.mjs +49 -0
- package/src/lib/archipelagos.mjs +111 -0
- package/src/lib/assurance.mjs +144 -0
- package/src/lib/baselines.mjs +107 -0
- package/src/lib/bundlability.mjs +123 -0
- package/src/lib/changed.mjs +157 -0
- package/src/lib/component-props.mjs +145 -0
- package/src/lib/config.mjs +451 -0
- package/src/lib/contracts.mjs +244 -0
- package/src/lib/data-flow.mjs +47 -0
- package/src/lib/declared-sources.mjs +101 -0
- package/src/lib/dock-inject.mjs +47 -0
- package/src/lib/effects.mjs +97 -0
- package/src/lib/eject.mjs +715 -0
- package/src/lib/evidence-json.mjs +74 -0
- package/src/lib/expect-calls.mjs +53 -0
- package/src/lib/finding-memory.mjs +0 -0
- package/src/lib/flow-calls.mjs +53 -0
- package/src/lib/framework.mjs +98 -0
- package/src/lib/host-rules.mjs +55 -0
- package/src/lib/host-sources.mjs +121 -0
- package/src/lib/island-placement.mjs +64 -0
- package/src/lib/island-render.mjs +105 -0
- package/src/lib/islands.mjs +112 -0
- package/src/lib/lagoon-bundle.mjs +138 -0
- package/src/lib/lagoon-declares.mjs +553 -0
- package/src/lib/lagoon-materialize.mjs +217 -0
- package/src/lib/lagoon-vite.mjs +788 -0
- package/src/lib/live-url.mjs +53 -0
- package/src/lib/node-aliases.mjs +73 -0
- package/src/lib/operations.mjs +145 -0
- package/src/lib/provenance-plugin.mjs +74 -0
- package/src/lib/region-refs.mjs +40 -0
- package/src/lib/remote.mjs +171 -0
- package/src/lib/scaffold.mjs +606 -0
- package/src/lib/screens.mjs +266 -0
- package/src/lib/snapshots.mjs +85 -0
- package/src/lib/stubs.mjs +114 -0
- package/src/lib/ts-project.mjs +42 -0
- package/src/lib/util.mjs +626 -0
- package/src/lib/worlds.mjs +236 -0
- package/src/lib/write-if-changed.mjs +35 -0
- package/src/lib/writes-coverage.mjs +32 -0
- package/src/playwright-lagoon.mjs +2305 -0
- package/src/run.mjs +385 -0
- package/src/runtime-harness.mjs +225 -0
- package/README.md +0 -3
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// RECORD `@motujs/*` IN THE APP'S package.json, so the package manager stops deleting them.
|
|
2
|
+
//
|
|
3
|
+
// A project that is not a workspace gets its `@motujs/*` from raw symlinks the CLI re-creates on every
|
|
4
|
+
// run. That works until `npm install`, which prunes them as EXTRANEOUS — nothing declares them, so as
|
|
5
|
+
// far as npm is concerned they are litter. Measured on shlink, a single-package npm app:
|
|
6
|
+
//
|
|
7
|
+
// $ npm install
|
|
8
|
+
// removed 9 packages
|
|
9
|
+
// $ npm run build
|
|
10
|
+
// Cannot find module '@motujs/react'
|
|
11
|
+
//
|
|
12
|
+
// The re-link on every motu command hides this from anyone who runs a motu command next, and not from
|
|
13
|
+
// CI, a fresh clone, or a teammate who just runs the app. The error points nowhere near the cause.
|
|
14
|
+
//
|
|
15
|
+
// A `file:` specifier fixes it properly: npm creates the link ITSELF, records it in the lockfile, and
|
|
16
|
+
// leaves it alone on every subsequent install. Verified on shlink — three consecutive `npm install`
|
|
17
|
+
// runs, nine links intact, `npm run types` clean, `motu check` green.
|
|
18
|
+
//
|
|
19
|
+
// AN EXPLICIT COMMAND, not a side effect of `init`. Editing an application's package.json is the
|
|
20
|
+
// host's call; what motu owes is to make the fix one word long and to say when it is needed.
|
|
21
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
22
|
+
import { relative, resolve } from 'node:path';
|
|
23
|
+
import { APP_ROOT, MOTU_CHECKOUT, color } from '../lib/util.mjs';
|
|
24
|
+
import { CLI_VERSION, INSTALLED } from '../lib/framework.mjs';
|
|
25
|
+
|
|
26
|
+
/** Package name -> its directory under `packages/`, for the ones a host can import. */
|
|
27
|
+
const PACKAGES = {
|
|
28
|
+
core: 'core',
|
|
29
|
+
react: 'react',
|
|
30
|
+
runtime: 'runtime',
|
|
31
|
+
types: 'types',
|
|
32
|
+
chrome: 'chrome',
|
|
33
|
+
coverage: 'coverage',
|
|
34
|
+
'debug-overlay': 'debug-overlay',
|
|
35
|
+
'adapter-next': 'adapters/next',
|
|
36
|
+
'adapter-angularjs': 'adapters/angularjs',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** The `file:` specifiers this project would need, relative to its own package.json. */
|
|
40
|
+
export function fileSpecifiers(appRoot = APP_ROOT, checkout = MOTU_CHECKOUT) {
|
|
41
|
+
const out = {};
|
|
42
|
+
for (const [name, dir] of Object.entries(PACKAGES)) {
|
|
43
|
+
const target = resolve(checkout, 'packages', dir);
|
|
44
|
+
if (!existsSync(target)) continue;
|
|
45
|
+
// RELATIVE, so two checkouts cloned side by side stay portable between machines. An absolute path
|
|
46
|
+
// would work here and be wrong in the repository the moment anyone else opened it.
|
|
47
|
+
out[`@motujs/${name}`] = `file:${relative(appRoot, target)}`;
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function linkCommand(argv) {
|
|
53
|
+
// CHECKOUT MODE ONLY. Everything above is about reaching a CHECKOUT's packages by path; installed
|
|
54
|
+
// from npm there is no checkout, and `fileSpecifiers` would write `file:` paths into a `packages/`
|
|
55
|
+
// directory that does not exist — the next `npm install` would then fail on every one of them.
|
|
56
|
+
// `motu init` already recorded real ranges, which is the fix this command exists to approximate.
|
|
57
|
+
// Exit 0, including under --check: an installed project is not out of date, it is a different mode.
|
|
58
|
+
if (INSTALLED) {
|
|
59
|
+
console.log(color.dim('motu link is for checkout mode only — it records `file:` paths into a motu clone.'));
|
|
60
|
+
console.log(color.dim(`This motu is installed from npm (@motujs/cli@${CLI_VERSION}), so @motujs/* are ordinary`));
|
|
61
|
+
console.log(color.dim('dependencies: `motu init` recorded them in package.json, and your package manager keeps them.'));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const pkgPath = resolve(APP_ROOT, 'package.json');
|
|
65
|
+
if (!existsSync(pkgPath)) {
|
|
66
|
+
console.error(color.red(`✗ no package.json at ${pkgPath}`));
|
|
67
|
+
process.exit(2);
|
|
68
|
+
}
|
|
69
|
+
let pkg;
|
|
70
|
+
try {
|
|
71
|
+
pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
72
|
+
} catch (err) {
|
|
73
|
+
console.error(color.red(`✗ ${pkgPath} is not readable JSON: ${err?.message ?? err}`));
|
|
74
|
+
process.exit(2);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const wanted = fileSpecifiers();
|
|
78
|
+
// DEV dependencies: motu is build-time for a bundled app, and every consumer here bundles. A host
|
|
79
|
+
// that ships `@motujs/*` to a server at runtime should move them itself — which is a decision, and
|
|
80
|
+
// this command does not make decisions about someone's manifest beyond the one it announces.
|
|
81
|
+
const field = pkg.devDependencies ? 'devDependencies' : 'dependencies';
|
|
82
|
+
const deps = (pkg[field] ??= {});
|
|
83
|
+
const added = [];
|
|
84
|
+
const changed = [];
|
|
85
|
+
for (const [name, spec] of Object.entries(wanted)) {
|
|
86
|
+
// Never overwrite a REAL range: a project that depends on a published `@motujs/*` has answered this
|
|
87
|
+
// question already, and replacing that with a path to somebody's checkout would be vandalism.
|
|
88
|
+
const current = pkg.dependencies?.[name] ?? pkg.devDependencies?.[name];
|
|
89
|
+
if (current && !current.startsWith('file:') && !current.startsWith('link:')) continue;
|
|
90
|
+
if (current === spec) continue;
|
|
91
|
+
(current ? changed : added).push(name);
|
|
92
|
+
deps[name] = spec;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (!added.length && !changed.length) {
|
|
96
|
+
console.log(color.green('✓') + ` package.json already records ${Object.keys(wanted).length} @motujs/* package(s)`);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (argv?.check) {
|
|
100
|
+
console.error(color.red(`✗ package.json does not record @motujs/*: ${[...added, ...changed].join(', ')}`));
|
|
101
|
+
console.error(color.dim(' run `motu link` — without it, `npm install` deletes them and the host build fails'));
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
105
|
+
console.log(color.green('✓') + ` recorded ${added.length + changed.length} @motujs/* package(s) in ${field}`);
|
|
106
|
+
for (const name of [...added, ...changed]) console.log(color.dim(` ${name}: ${deps[name]}`));
|
|
107
|
+
console.log('');
|
|
108
|
+
console.log(color.dim(' Run your package manager once to materialise them (`npm install`).'));
|
|
109
|
+
console.log(color.dim(' They survive every install after that — which raw symlinks did not.'));
|
|
110
|
+
}
|