@scenar/cli 0.2.1 → 0.4.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/example-bundle/embed.js +1 -0
- package/example-bundle/pack-manifest.json +6 -0
- package/package.json +4 -8
- package/src/__tests__/embed-loader.test.ts +29 -0
- package/src/__tests__/embed-snippet.test.ts +48 -1
- package/src/__tests__/install-command.test.ts +97 -0
- package/src/__tests__/local-url.test.ts +17 -0
- package/src/__tests__/run-install.test.ts +222 -0
- package/src/api.d.ts +3 -1
- package/src/api.d.ts.map +1 -1
- package/src/api.js +3 -1
- package/src/api.js.map +1 -1
- package/src/api.ts +10 -1
- package/src/commands/install.d.ts +3 -0
- package/src/commands/install.d.ts.map +1 -0
- package/src/commands/install.js +67 -0
- package/src/commands/install.js.map +1 -0
- package/src/commands/install.ts +89 -0
- package/src/commands/pack.js +2 -2
- package/src/commands/pack.js.map +1 -1
- package/src/commands/pack.ts +2 -2
- package/src/commands/publish.d.ts.map +1 -1
- package/src/commands/publish.js +3 -1
- package/src/commands/publish.js.map +1 -1
- package/src/commands/publish.ts +5 -1
- package/src/commands/serve.d.ts.map +1 -1
- package/src/commands/serve.js +3 -2
- package/src/commands/serve.js.map +1 -1
- package/src/commands/serve.ts +5 -2
- package/src/commands/try.js +1 -1
- package/src/commands/try.ts +1 -1
- package/src/{deploy → embed}/embed-snippet.d.ts +16 -0
- package/src/embed/embed-snippet.d.ts.map +1 -0
- package/src/{deploy → embed}/embed-snippet.js +27 -0
- package/src/embed/embed-snippet.js.map +1 -0
- package/src/{deploy → embed}/embed-snippet.ts +28 -0
- package/src/index.d.ts.map +1 -1
- package/src/index.js +3 -5
- package/src/index.js.map +1 -1
- package/src/index.ts +3 -5
- package/src/install/run-install.d.ts +72 -0
- package/src/install/run-install.d.ts.map +1 -0
- package/src/install/run-install.js +378 -0
- package/src/install/run-install.js.map +1 -0
- package/src/install/run-install.ts +461 -0
- package/src/install/scaffold.d.ts +29 -0
- package/src/install/scaffold.d.ts.map +1 -0
- package/src/install/scaffold.js +233 -0
- package/src/install/scaffold.js.map +1 -0
- package/src/install/scaffold.ts +255 -0
- package/src/pack/embed-loader.d.ts +18 -0
- package/src/pack/embed-loader.d.ts.map +1 -0
- package/src/pack/embed-loader.js +25 -0
- package/src/pack/embed-loader.js.map +1 -0
- package/src/pack/embed-loader.ts +27 -0
- package/src/pack/pack-manifest.d.ts +1 -1
- package/src/pack/pack-manifest.d.ts.map +1 -1
- package/src/pack/pack-manifest.ts +1 -1
- package/src/pack/run-pack.d.ts.map +1 -1
- package/src/pack/run-pack.js +6 -0
- package/src/pack/run-pack.js.map +1 -1
- package/src/pack/run-pack.ts +7 -0
- package/src/publish/publish-flow.d.ts +3 -3
- package/src/publish/publish-flow.js +3 -3
- package/src/publish/publish-flow.ts +3 -3
- package/src/publish/run-publish.d.ts +2 -0
- package/src/publish/run-publish.d.ts.map +1 -1
- package/src/publish/run-publish.js +3 -2
- package/src/publish/run-publish.js.map +1 -1
- package/src/publish/run-publish.ts +5 -2
- package/src/render/detect-render-export.d.ts +2 -2
- package/src/render/detect-render-export.js +2 -2
- package/src/render/detect-render-export.ts +2 -2
- package/src/serve/local-url.d.ts +8 -0
- package/src/serve/local-url.d.ts.map +1 -0
- package/src/serve/local-url.js +21 -0
- package/src/serve/local-url.js.map +1 -0
- package/src/serve/local-url.ts +20 -0
- package/src/serve/run-serve.d.ts +2 -0
- package/src/serve/run-serve.d.ts.map +1 -1
- package/src/serve/run-serve.js +4 -3
- package/src/serve/run-serve.js.map +1 -1
- package/src/serve/run-serve.ts +6 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/src/__tests__/deploy-command.test.ts +0 -45
- package/src/__tests__/deploy-flow.test.ts +0 -125
- package/src/__tests__/deploy-upload.test.ts +0 -39
- package/src/commands/deploy.d.ts +0 -3
- package/src/commands/deploy.d.ts.map +0 -1
- package/src/commands/deploy.js +0 -150
- package/src/commands/deploy.js.map +0 -1
- package/src/commands/deploy.ts +0 -186
- package/src/commands/preview.d.ts +0 -3
- package/src/commands/preview.d.ts.map +0 -1
- package/src/commands/preview.js +0 -93
- package/src/commands/preview.js.map +0 -1
- package/src/commands/preview.ts +0 -138
- package/src/deploy/client.d.ts +0 -20
- package/src/deploy/client.d.ts.map +0 -1
- package/src/deploy/client.js +0 -22
- package/src/deploy/client.js.map +0 -1
- package/src/deploy/client.ts +0 -28
- package/src/deploy/deploy-flow.d.ts +0 -78
- package/src/deploy/deploy-flow.d.ts.map +0 -1
- package/src/deploy/deploy-flow.js +0 -53
- package/src/deploy/deploy-flow.js.map +0 -1
- package/src/deploy/deploy-flow.ts +0 -115
- package/src/deploy/embed-snippet.d.ts.map +0 -1
- package/src/deploy/embed-snippet.js.map +0 -1
- package/src/deploy/upload.d.ts +0 -10
- package/src/deploy/upload.d.ts.map +0 -1
- package/src/deploy/upload.js +0 -23
- package/src/deploy/upload.js.map +0 -1
- package/src/deploy/upload.ts +0 -29
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { runInstall, type PackageManager } from "../install/run-install.js";
|
|
4
|
+
|
|
5
|
+
interface InstallCommandOptions {
|
|
6
|
+
dir?: string;
|
|
7
|
+
install?: boolean; // commander sets this to false for --no-install
|
|
8
|
+
packageManager?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const PACKAGE_MANAGERS: readonly PackageManager[] = ["npm", "yarn", "pnpm"];
|
|
12
|
+
|
|
13
|
+
export function registerInstallCommand(program: Command): void {
|
|
14
|
+
program
|
|
15
|
+
.command("install")
|
|
16
|
+
.description(
|
|
17
|
+
"Bootstrap a Scenar demos project in one step.\n\n" +
|
|
18
|
+
"Scaffolds a package.json and a runnable starter tour under\n" +
|
|
19
|
+
"tours/example-tour/ if the directory is empty, adds the given\n" +
|
|
20
|
+
"component packages as ordinary dependencies, and runs your package\n" +
|
|
21
|
+
"manager. Re-run any time — existing files are never overwritten, so\n" +
|
|
22
|
+
"your authored tours are always preserved.\n\n" +
|
|
23
|
+
"Component packages are consumed as normal dependencies — import and\n" +
|
|
24
|
+
"compose them into the tours you author under tours/. Specs are\n" +
|
|
25
|
+
"resolver-agnostic: a registry version (@stigmer/react@1.2.0),\n" +
|
|
26
|
+
"workspace:*, file:../pkg, or a git URL all work; resolution is your\n" +
|
|
27
|
+
"package manager's job.\n\n" +
|
|
28
|
+
"Inside a monorepo, the project is detected as a workspace member and\n" +
|
|
29
|
+
"the install runs at the workspace root.",
|
|
30
|
+
)
|
|
31
|
+
.argument(
|
|
32
|
+
"[packages...]",
|
|
33
|
+
"component packages to add as dependencies (e.g. @stigmer/react)",
|
|
34
|
+
)
|
|
35
|
+
.option("--dir <path>", "project directory (default: current directory)")
|
|
36
|
+
.option("--no-install", "scaffold and record dependencies but skip the install")
|
|
37
|
+
.option(
|
|
38
|
+
"--package-manager <pm>",
|
|
39
|
+
"force npm | yarn | pnpm instead of auto-detecting",
|
|
40
|
+
)
|
|
41
|
+
.action(async (packages: string[], options: InstallCommandOptions) => {
|
|
42
|
+
try {
|
|
43
|
+
const cwd = path.resolve(options.dir ?? process.cwd());
|
|
44
|
+
|
|
45
|
+
const installResult = runInstall({
|
|
46
|
+
cwd,
|
|
47
|
+
packages: packages ?? [],
|
|
48
|
+
onLog: (line) => process.stderr.write(`${line}\n`),
|
|
49
|
+
skipInstall: options.install === false,
|
|
50
|
+
packageManager: parsePackageManager(options.packageManager),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
printNextSteps(cwd, installResult.installRan);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
56
|
+
process.stderr.write(`\x1b[31mError:\x1b[0m ${msg}\n`);
|
|
57
|
+
process.exitCode = 1;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function parsePackageManager(value: string | undefined): PackageManager | undefined {
|
|
63
|
+
if (value === undefined) return undefined;
|
|
64
|
+
if ((PACKAGE_MANAGERS as readonly string[]).includes(value)) {
|
|
65
|
+
return value as PackageManager;
|
|
66
|
+
}
|
|
67
|
+
throw new Error(
|
|
68
|
+
`invalid --package-manager "${value}"; expected one of ${PACKAGE_MANAGERS.join(", ")}.`,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function printNextSteps(cwd: string, installRan: boolean): void {
|
|
73
|
+
const rel = path.relative(process.cwd(), cwd);
|
|
74
|
+
// Prefer a short relative path, but fall back to the absolute path when the
|
|
75
|
+
// target is outside the current directory (avoids a wall of "../").
|
|
76
|
+
const where = rel === "" ? "." : rel.startsWith("..") ? cwd : rel;
|
|
77
|
+
process.stderr.write(`\n\x1b[32m✓\x1b[0m Scenar demos project ready in ${where}/\n`);
|
|
78
|
+
if (!installRan) {
|
|
79
|
+
process.stderr.write(
|
|
80
|
+
` \x1b[33m●\x1b[0m Install skipped — run your package manager before packing.\n`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
process.stderr.write(` Next:\n`);
|
|
84
|
+
process.stderr.write(` 1. \`scenar pack tours/example-tour\` to preview the starter tour.\n`);
|
|
85
|
+
process.stderr.write(` 2. Edit tours/example-tour/index.tsx — swap the shells for your\n`);
|
|
86
|
+
process.stderr.write(` real components (add them with \`scenar install <your-pkg>\`).\n`);
|
|
87
|
+
process.stderr.write(` 3. Wire any data they fetch in tours/example-tour/.scenar/providers.tsx.\n`);
|
|
88
|
+
process.stderr.write(` 4. \`scenar pack\` then \`scenar publish\` to ship the embed.\n`);
|
|
89
|
+
}
|
package/src/commands/pack.js
CHANGED
|
@@ -8,11 +8,11 @@ export function registerPackCommand(program) {
|
|
|
8
8
|
program
|
|
9
9
|
.command("pack")
|
|
10
10
|
.description("Bundle a scenario into a self-contained, hosted embed.\n\n" +
|
|
11
|
-
"Accepts the same scenario directory as `render
|
|
11
|
+
"Accepts the same scenario directory as `render`\n" +
|
|
12
12
|
"(steps.ts + an index.tsx that exports renderStep, plus an\n" +
|
|
13
13
|
"optional .scenar/providers.tsx and narration/). Produces a static\n" +
|
|
14
14
|
"bundle that boots ScenarioPlayer in the browser, ready for\n" +
|
|
15
|
-
"`scenar serve
|
|
15
|
+
"`scenar serve` or `scenar publish`.\n\n" +
|
|
16
16
|
"The bundle contains index.html, hashed JS/CSS, a scenario.json\n" +
|
|
17
17
|
"descriptor, and a pack-manifest.json listing every file with its\n" +
|
|
18
18
|
"lowercase-hex sha256 and content type. Output stays within the\n" +
|
package/src/commands/pack.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pack.js","sourceRoot":"","sources":["../../../src/commands/pack.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,yEAAyE;AACzE,MAAM,aAAa,GAAG,gBAAgB,CAAC,KAAK,CAAC;AAE7C,0CAA0C;AAC1C,MAAM,oBAAoB,GAAG,gBAAgB,CAAC,MAAM,CAAC;AASrD,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAClD,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CACV,4DAA4D;QAC1D,
|
|
1
|
+
{"version":3,"file":"pack.js","sourceRoot":"","sources":["../../../src/commands/pack.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,yEAAyE;AACzE,MAAM,aAAa,GAAG,gBAAgB,CAAC,KAAK,CAAC;AAE7C,0CAA0C;AAC1C,MAAM,oBAAoB,GAAG,gBAAgB,CAAC,MAAM,CAAC;AASrD,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAClD,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CACV,4DAA4D;QAC1D,mD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AC,MAAM,IAAI,CAAC,CAAC;QAClE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACnE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAC;YACvD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,GAAG,KAAK,IAAI,CAAC;IACtC,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;IACnE,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;AACrD,CAAC"}
|
package/src/commands/pack.ts
CHANGED
|
@@ -20,11 +20,11 @@ export function registerPackCommand(program: Command): void {
|
|
|
20
20
|
.command("pack")
|
|
21
21
|
.description(
|
|
22
22
|
"Bundle a scenario into a self-contained, hosted embed.\n\n" +
|
|
23
|
-
"Accepts the same scenario directory as `render
|
|
23
|
+
"Accepts the same scenario directory as `render`\n" +
|
|
24
24
|
"(steps.ts + an index.tsx that exports renderStep, plus an\n" +
|
|
25
25
|
"optional .scenar/providers.tsx and narration/). Produces a static\n" +
|
|
26
26
|
"bundle that boots ScenarioPlayer in the browser, ready for\n" +
|
|
27
|
-
"`scenar serve
|
|
27
|
+
"`scenar serve` or `scenar publish`.\n\n" +
|
|
28
28
|
"The bundle contains index.html, hashed JS/CSS, a scenario.json\n" +
|
|
29
29
|
"descriptor, and a pack-manifest.json listing every file with its\n" +
|
|
30
30
|
"lowercase-hex sha256 and content type. Output stays within the\n" +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../src/commands/publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../src/commands/publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAyE7D"}
|
package/src/commands/publish.js
CHANGED
|
@@ -27,7 +27,7 @@ export function registerPublishCommand(program) {
|
|
|
27
27
|
process.stderr.write(`Bundle: ${bundleDir}\n`);
|
|
28
28
|
process.stderr.write(`Target: ${options.org ? `${options.org}/` : ""}${options.repo ?? "scenar-embeds"}` +
|
|
29
29
|
`/${options.path ?? "(scenario slug)"} (GitHub Pages)\n\n`);
|
|
30
|
-
const { result, viewport, recordedViewport, snippet } = await runPublish({
|
|
30
|
+
const { result, viewport, recordedViewport, snippet, enhancedSnippet } = await runPublish({
|
|
31
31
|
bundleDir,
|
|
32
32
|
repo: options.repo,
|
|
33
33
|
path: options.path,
|
|
@@ -49,6 +49,8 @@ export function registerPublishCommand(program) {
|
|
|
49
49
|
}
|
|
50
50
|
process.stderr.write("\n Embed snippet (paste into any page):\n\n");
|
|
51
51
|
process.stderr.write(`${indent(snippet)}\n`);
|
|
52
|
+
process.stderr.write("\n Or, for auto-fit + light/dark sync, the <scenar-embed> loader:\n\n");
|
|
53
|
+
process.stderr.write(`${indent(enhancedSnippet)}\n`);
|
|
52
54
|
}
|
|
53
55
|
catch (error) {
|
|
54
56
|
const msg = error instanceof Error ? error.message : String(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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AAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC7C,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,wEAAwE,CACzE,CAAC;YACF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QACvD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACnE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAC;YACvD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC;AAED,6EAA6E;AAC7E,SAAS,MAAM,CAAC,KAAa;IAC3B,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACpC,CAAC"}
|
package/src/commands/publish.ts
CHANGED
|
@@ -42,7 +42,7 @@ export function registerPublishCommand(program: Command): void {
|
|
|
42
42
|
`/${options.path ?? "(scenario slug)"} (GitHub Pages)\n\n`,
|
|
43
43
|
);
|
|
44
44
|
|
|
45
|
-
const { result, viewport, recordedViewport, snippet } = await runPublish({
|
|
45
|
+
const { result, viewport, recordedViewport, snippet, enhancedSnippet } = await runPublish({
|
|
46
46
|
bundleDir,
|
|
47
47
|
repo: options.repo,
|
|
48
48
|
path: options.path,
|
|
@@ -72,6 +72,10 @@ export function registerPublishCommand(program: Command): void {
|
|
|
72
72
|
}
|
|
73
73
|
process.stderr.write("\n Embed snippet (paste into any page):\n\n");
|
|
74
74
|
process.stderr.write(`${indent(snippet)}\n`);
|
|
75
|
+
process.stderr.write(
|
|
76
|
+
"\n Or, for auto-fit + light/dark sync, the <scenar-embed> loader:\n\n",
|
|
77
|
+
);
|
|
78
|
+
process.stderr.write(`${indent(enhancedSnippet)}\n`);
|
|
75
79
|
} catch (error) {
|
|
76
80
|
const msg = error instanceof Error ? error.message : String(error);
|
|
77
81
|
process.stderr.write(`\x1b[31mError:\x1b[0m ${msg}\n`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../../src/commands/serve.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgBpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../../src/commands/serve.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgBpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA+D3D"}
|
package/src/commands/serve.js
CHANGED
|
@@ -14,8 +14,7 @@ export function registerServeCommand(program) {
|
|
|
14
14
|
"Prints the URL plus a ready-to-paste responsive <iframe> snippet, then\n" +
|
|
15
15
|
"stays running until you press Ctrl+C.\n\n" +
|
|
16
16
|
"This is the zero-infrastructure way to view an embed: no backend, no\n" +
|
|
17
|
-
"account. For a permanent public URL, use `scenar publish` (GitHub
|
|
18
|
-
"Pages) or `scenar deploy` (Scenar Cloud).")
|
|
17
|
+
"account. For a permanent public URL, use `scenar publish` (GitHub Pages).")
|
|
19
18
|
.argument("<bundleDir>", "path to a packed bundle directory (from scenar pack)")
|
|
20
19
|
.option("--port <number>", `port to listen on (default: ${DEFAULT_PORT})`, String(DEFAULT_PORT))
|
|
21
20
|
.option("--host <host>", `host/interface to bind (default: ${DEFAULT_HOST})`, DEFAULT_HOST)
|
|
@@ -45,6 +44,8 @@ export function registerServeCommand(program) {
|
|
|
45
44
|
}
|
|
46
45
|
process.stderr.write("\n Embed snippet (paste into any page):\n\n");
|
|
47
46
|
process.stderr.write(`${indent(result.snippet)}\n`);
|
|
47
|
+
process.stderr.write("\n Or, for auto-fit + light/dark sync, the <scenar-embed> loader:\n\n");
|
|
48
|
+
process.stderr.write(`${indent(result.enhancedSnippet)}\n`);
|
|
48
49
|
process.stderr.write("\n Press Ctrl+C to stop.\n");
|
|
49
50
|
if (options.open) {
|
|
50
51
|
openInBrowser(result.url);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/commands/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,wEAAwE;AACxE,MAAM,YAAY,GAAG,IAAI,CAAC;AAE1B,yEAAyE;AACzE,MAAM,YAAY,GAAG,WAAW,CAAC;AAQjC,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACnD,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CACV,4DAA4D;QAC1D,yEAAyE;QACzE,uEAAuE;QACvE,0EAA0E;QAC1E,2CAA2C;QAC3C,wEAAwE;QACxE,
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/commands/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,wEAAwE;AACxE,MAAM,YAAY,GAAG,IAAI,CAAC;AAE1B,yEAAyE;AACzE,MAAM,YAAY,GAAG,WAAW,CAAC;AAQjC,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACnD,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CACV,4DAA4D;QAC1D,yEAAyE;QACzE,uEAAuE;QAC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paste responsive <iframe> snippet, then\n" +
|
|
27
27
|
"stays running until you press Ctrl+C.\n\n" +
|
|
28
28
|
"This is the zero-infrastructure way to view an embed: no backend, no\n" +
|
|
29
|
-
"account. For a permanent public URL, use `scenar publish` (GitHub
|
|
30
|
-
"Pages) or `scenar deploy` (Scenar Cloud).",
|
|
29
|
+
"account. For a permanent public URL, use `scenar publish` (GitHub Pages).",
|
|
31
30
|
)
|
|
32
31
|
.argument("<bundleDir>", "path to a packed bundle directory (from scenar pack)")
|
|
33
32
|
.option("--port <number>", `port to listen on (default: ${DEFAULT_PORT})`, String(DEFAULT_PORT))
|
|
@@ -63,6 +62,10 @@ export function registerServeCommand(program: Command): void {
|
|
|
63
62
|
}
|
|
64
63
|
process.stderr.write("\n Embed snippet (paste into any page):\n\n");
|
|
65
64
|
process.stderr.write(`${indent(result.snippet)}\n`);
|
|
65
|
+
process.stderr.write(
|
|
66
|
+
"\n Or, for auto-fit + light/dark sync, the <scenar-embed> loader:\n\n",
|
|
67
|
+
);
|
|
68
|
+
process.stderr.write(`${indent(result.enhancedSnippet)}\n`);
|
|
66
69
|
process.stderr.write("\n Press Ctrl+C to stop.\n");
|
|
67
70
|
|
|
68
71
|
if (options.open) {
|
package/src/commands/try.js
CHANGED
|
@@ -24,7 +24,7 @@ export function registerTryCommand(program) {
|
|
|
24
24
|
"ready-to-paste <iframe> snippet, then stays running until Ctrl+C.\n\n" +
|
|
25
25
|
"This is the fastest way to see what a Scenar embed looks like before\n" +
|
|
26
26
|
"wiring up your own app. To build a tour from your components, see\n" +
|
|
27
|
-
"`scenar
|
|
27
|
+
"`scenar install`; to host one, see `scenar publish`.")
|
|
28
28
|
.option("--port <number>", `port to listen on (default: ${DEFAULT_PORT})`, String(DEFAULT_PORT))
|
|
29
29
|
.option("--host <host>", `host/interface to bind (default: ${DEFAULT_HOST})`, DEFAULT_HOST)
|
|
30
30
|
.option("--open", "open the embed in your default browser")
|
package/src/commands/try.ts
CHANGED
|
@@ -37,7 +37,7 @@ export function registerTryCommand(program: Command): void {
|
|
|
37
37
|
"ready-to-paste <iframe> snippet, then stays running until Ctrl+C.\n\n" +
|
|
38
38
|
"This is the fastest way to see what a Scenar embed looks like before\n" +
|
|
39
39
|
"wiring up your own app. To build a tour from your components, see\n" +
|
|
40
|
-
"`scenar
|
|
40
|
+
"`scenar install`; to host one, see `scenar publish`.",
|
|
41
41
|
)
|
|
42
42
|
.option("--port <number>", `port to listen on (default: ${DEFAULT_PORT})`, String(DEFAULT_PORT))
|
|
43
43
|
.option("--host <host>", `host/interface to bind (default: ${DEFAULT_HOST})`, DEFAULT_HOST)
|
|
@@ -24,4 +24,20 @@ export interface EmbedSnippetInput {
|
|
|
24
24
|
* Pure function — returns the snippet string; the caller decides where to print.
|
|
25
25
|
*/
|
|
26
26
|
export declare function buildEmbedSnippet(input: EmbedSnippetInput): string;
|
|
27
|
+
/**
|
|
28
|
+
* Build the *enhanced* embed snippet — the optional `<scenar-embed>` loader of
|
|
29
|
+
* DD-002/DD-005. A single `<script>` registers the custom element (the bundle's
|
|
30
|
+
* sibling `embed.js`, copied in by `scenar pack`), and the tag then auto-fits to
|
|
31
|
+
* the embed's reported size and syncs the host's light/dark theme. No viewport
|
|
32
|
+
* math is needed in the snippet: the element adopts the embed's exact aspect
|
|
33
|
+
* ratio from its first `resize`, falling back to the recorded baseline until then.
|
|
34
|
+
*
|
|
35
|
+
* The loader URL is resolved as `embed.js` relative to the embed URL, so it
|
|
36
|
+
* points at the copy that ships inside the bundle (works on GitHub Pages, a
|
|
37
|
+
* local `serve`, or any static host). Attribute values are escaped, since the
|
|
38
|
+
* snippet is copy-pasted into third-party HTML.
|
|
39
|
+
*
|
|
40
|
+
* Pure function — returns the snippet string; the caller decides where to print.
|
|
41
|
+
*/
|
|
42
|
+
export declare function buildEnhancedEmbedSnippet(input: EmbedSnippetInput): string;
|
|
27
43
|
//# sourceMappingURL=embed-snippet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed-snippet.d.ts","sourceRoot":"","sources":["../../../src/embed/embed-snippet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,4CAA4C;AAC5C,MAAM,WAAW,iBAAiB;IAChC,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAelE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAW1E"}
|
|
@@ -29,6 +29,33 @@ export function buildEmbedSnippet(input) {
|
|
|
29
29
|
`</div>`,
|
|
30
30
|
].join("\n");
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Build the *enhanced* embed snippet — the optional `<scenar-embed>` loader of
|
|
34
|
+
* DD-002/DD-005. A single `<script>` registers the custom element (the bundle's
|
|
35
|
+
* sibling `embed.js`, copied in by `scenar pack`), and the tag then auto-fits to
|
|
36
|
+
* the embed's reported size and syncs the host's light/dark theme. No viewport
|
|
37
|
+
* math is needed in the snippet: the element adopts the embed's exact aspect
|
|
38
|
+
* ratio from its first `resize`, falling back to the recorded baseline until then.
|
|
39
|
+
*
|
|
40
|
+
* The loader URL is resolved as `embed.js` relative to the embed URL, so it
|
|
41
|
+
* points at the copy that ships inside the bundle (works on GitHub Pages, a
|
|
42
|
+
* local `serve`, or any static host). Attribute values are escaped, since the
|
|
43
|
+
* snippet is copy-pasted into third-party HTML.
|
|
44
|
+
*
|
|
45
|
+
* Pure function — returns the snippet string; the caller decides where to print.
|
|
46
|
+
*/
|
|
47
|
+
export function buildEnhancedEmbedSnippet(input) {
|
|
48
|
+
const { embedUrl } = input;
|
|
49
|
+
const title = input.title ?? "Scenar embed";
|
|
50
|
+
const loaderUrl = new URL("embed.js", embedUrl).toString();
|
|
51
|
+
return [
|
|
52
|
+
`<script type="module" src="${escapeAttr(loaderUrl)}"></script>`,
|
|
53
|
+
`<scenar-embed`,
|
|
54
|
+
` src="${escapeAttr(embedUrl)}"`,
|
|
55
|
+
` title="${escapeAttr(title)}"`,
|
|
56
|
+
`></scenar-embed>`,
|
|
57
|
+
].join("\n");
|
|
58
|
+
}
|
|
32
59
|
/** Escape a string for safe interpolation into a double-quoted HTML attribute. */
|
|
33
60
|
function escapeAttr(value) {
|
|
34
61
|
return value
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed-snippet.js","sourceRoot":"","sources":["../../../src/embed/embed-snippet.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAwB;IACxD,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACrC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,cAAc,CAAC;IAC5C,OAAO;QACL,sDAAsD,QAAQ,CAAC,KAAK,mBAAmB,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAC,MAAM,IAAI;QAC5H,WAAW;QACX,YAAY,UAAU,CAAC,QAAQ,CAAC,GAAG;QACnC,cAAc,UAAU,CAAC,KAAK,CAAC,GAAG;QAClC,oBAAoB;QACpB,uEAAuE;QACvE,kCAAkC;QAClC,qBAAqB;QACrB,cAAc;QACd,QAAQ;KACT,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAwB;IAChE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC3B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,cAAc,CAAC;IAC5C,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC3D,OAAO;QACL,8BAA8B,UAAU,CAAC,SAAS,CAAC,aAAa;QAChE,eAAe;QACf,UAAU,UAAU,CAAC,QAAQ,CAAC,GAAG;QACjC,YAAY,UAAU,CAAC,KAAK,CAAC,GAAG;QAChC,kBAAkB;KACnB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,kFAAkF;AAClF,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,KAAK;SACT,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -42,6 +42,34 @@ export function buildEmbedSnippet(input: EmbedSnippetInput): string {
|
|
|
42
42
|
].join("\n");
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Build the *enhanced* embed snippet — the optional `<scenar-embed>` loader of
|
|
47
|
+
* DD-002/DD-005. A single `<script>` registers the custom element (the bundle's
|
|
48
|
+
* sibling `embed.js`, copied in by `scenar pack`), and the tag then auto-fits to
|
|
49
|
+
* the embed's reported size and syncs the host's light/dark theme. No viewport
|
|
50
|
+
* math is needed in the snippet: the element adopts the embed's exact aspect
|
|
51
|
+
* ratio from its first `resize`, falling back to the recorded baseline until then.
|
|
52
|
+
*
|
|
53
|
+
* The loader URL is resolved as `embed.js` relative to the embed URL, so it
|
|
54
|
+
* points at the copy that ships inside the bundle (works on GitHub Pages, a
|
|
55
|
+
* local `serve`, or any static host). Attribute values are escaped, since the
|
|
56
|
+
* snippet is copy-pasted into third-party HTML.
|
|
57
|
+
*
|
|
58
|
+
* Pure function — returns the snippet string; the caller decides where to print.
|
|
59
|
+
*/
|
|
60
|
+
export function buildEnhancedEmbedSnippet(input: EmbedSnippetInput): string {
|
|
61
|
+
const { embedUrl } = input;
|
|
62
|
+
const title = input.title ?? "Scenar embed";
|
|
63
|
+
const loaderUrl = new URL("embed.js", embedUrl).toString();
|
|
64
|
+
return [
|
|
65
|
+
`<script type="module" src="${escapeAttr(loaderUrl)}"></script>`,
|
|
66
|
+
`<scenar-embed`,
|
|
67
|
+
` src="${escapeAttr(embedUrl)}"`,
|
|
68
|
+
` title="${escapeAttr(title)}"`,
|
|
69
|
+
`></scenar-embed>`,
|
|
70
|
+
].join("\n");
|
|
71
|
+
}
|
|
72
|
+
|
|
45
73
|
/** Escape a string for safe interpolation into a double-quoted HTML attribute. */
|
|
46
74
|
function escapeAttr(value: string): string {
|
|
47
75
|
return value
|
package/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,wBAAgB,aAAa,IAAI,OAAO,CAkBvC;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAGxC"}
|
package/src/index.js
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { registerValidateCommand } from "./commands/validate.js";
|
|
3
3
|
import { registerNarrateCommand } from "./commands/narrate.js";
|
|
4
|
-
import {
|
|
4
|
+
import { registerInstallCommand } from "./commands/install.js";
|
|
5
5
|
import { registerRenderCommand } from "./commands/render.js";
|
|
6
6
|
import { registerPackCommand } from "./commands/pack.js";
|
|
7
7
|
import { registerServeCommand } from "./commands/serve.js";
|
|
8
8
|
import { registerTryCommand } from "./commands/try.js";
|
|
9
9
|
import { registerPublishCommand } from "./commands/publish.js";
|
|
10
|
-
import { registerDeployCommand } from "./commands/deploy.js";
|
|
11
10
|
export function createProgram() {
|
|
12
11
|
const program = new Command();
|
|
13
12
|
program
|
|
14
13
|
.name("scenar")
|
|
15
|
-
.description("Scenar CLI —
|
|
14
|
+
.description("Scenar CLI — install a demos project, author scenarios, then pack, serve, and publish embeds.")
|
|
16
15
|
.version("0.0.1");
|
|
17
16
|
registerValidateCommand(program);
|
|
18
17
|
registerNarrateCommand(program);
|
|
19
18
|
registerRenderCommand(program);
|
|
20
|
-
|
|
19
|
+
registerInstallCommand(program);
|
|
21
20
|
registerPackCommand(program);
|
|
22
21
|
registerServeCommand(program);
|
|
23
22
|
registerTryCommand(program);
|
|
24
23
|
registerPublishCommand(program);
|
|
25
|
-
registerDeployCommand(program);
|
|
26
24
|
return program;
|
|
27
25
|
}
|
|
28
26
|
export function run(argv) {
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","source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@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { registerValidateCommand } from "./commands/validate.js";
|
|
3
3
|
import { registerNarrateCommand } from "./commands/narrate.js";
|
|
4
|
-
import {
|
|
4
|
+
import { registerInstallCommand } from "./commands/install.js";
|
|
5
5
|
import { registerRenderCommand } from "./commands/render.js";
|
|
6
6
|
import { registerPackCommand } from "./commands/pack.js";
|
|
7
7
|
import { registerServeCommand } from "./commands/serve.js";
|
|
8
8
|
import { registerTryCommand } from "./commands/try.js";
|
|
9
9
|
import { registerPublishCommand } from "./commands/publish.js";
|
|
10
|
-
import { registerDeployCommand } from "./commands/deploy.js";
|
|
11
10
|
|
|
12
11
|
export function createProgram(): Command {
|
|
13
12
|
const program = new Command();
|
|
14
13
|
|
|
15
14
|
program
|
|
16
15
|
.name("scenar")
|
|
17
|
-
.description("Scenar CLI —
|
|
16
|
+
.description("Scenar CLI — install a demos project, author scenarios, then pack, serve, and publish embeds.")
|
|
18
17
|
.version("0.0.1");
|
|
19
18
|
|
|
20
19
|
registerValidateCommand(program);
|
|
21
20
|
registerNarrateCommand(program);
|
|
22
21
|
registerRenderCommand(program);
|
|
23
|
-
|
|
22
|
+
registerInstallCommand(program);
|
|
24
23
|
registerPackCommand(program);
|
|
25
24
|
registerServeCommand(program);
|
|
26
25
|
registerTryCommand(program);
|
|
27
26
|
registerPublishCommand(program);
|
|
28
|
-
registerDeployCommand(program);
|
|
29
27
|
|
|
30
28
|
return program;
|
|
31
29
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** Supported package managers, detected by lockfile / workspace manifest. */
|
|
2
|
+
export type PackageManager = "npm" | "yarn" | "pnpm";
|
|
3
|
+
/** A dependency parsed from a positional install argument. */
|
|
4
|
+
export interface ParsedSpec {
|
|
5
|
+
/** The package name (registry key written into `dependencies`). */
|
|
6
|
+
readonly name: string;
|
|
7
|
+
/**
|
|
8
|
+
* The version range / locator to record. Empty string means "bare" — the
|
|
9
|
+
* concrete value is decided at merge time (`workspace:*` for a workspace
|
|
10
|
+
* member, otherwise `*`, later pinned to the installed version).
|
|
11
|
+
*/
|
|
12
|
+
readonly range: string;
|
|
13
|
+
}
|
|
14
|
+
export interface RunInstallOptions {
|
|
15
|
+
/** Project directory to operate in (absolute or relative to cwd). */
|
|
16
|
+
readonly cwd: string;
|
|
17
|
+
/** Positional dependency specs to add (names, ranges, file:/git/workspace). */
|
|
18
|
+
readonly packages: readonly string[];
|
|
19
|
+
/** Line-oriented log sink (the CLI wires this to stderr). */
|
|
20
|
+
readonly onLog: (line: string) => void;
|
|
21
|
+
/** Scaffold and record deps but skip the package-manager subprocess. */
|
|
22
|
+
readonly skipInstall?: boolean;
|
|
23
|
+
/** Force a package manager instead of detecting one. */
|
|
24
|
+
readonly packageManager?: PackageManager;
|
|
25
|
+
}
|
|
26
|
+
export interface RunInstallResult {
|
|
27
|
+
/** Whether a fresh project was scaffolded (no prior `package.json`). */
|
|
28
|
+
readonly scaffolded: boolean;
|
|
29
|
+
/** Files created by scaffolding, relative to the project directory. */
|
|
30
|
+
readonly scaffoldCreated: readonly string[];
|
|
31
|
+
/** Dependencies added (or already present) from the positional specs. */
|
|
32
|
+
readonly added: readonly ParsedSpec[];
|
|
33
|
+
/** The package manager used. */
|
|
34
|
+
readonly packageManager: PackageManager;
|
|
35
|
+
/** Workspace root if the project is a workspace member, else null. */
|
|
36
|
+
readonly workspaceRoot: string | null;
|
|
37
|
+
/** Whether the package-manager install actually ran. */
|
|
38
|
+
readonly installRan: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Bootstrap a Scenar demos project: scaffold (if empty), record the requested
|
|
42
|
+
* component packages as ordinary dependencies, and run the package manager.
|
|
43
|
+
*
|
|
44
|
+
* The command is intentionally resolver-agnostic — it only writes dependency
|
|
45
|
+
* entries and delegates resolution to the package manager — so a positional
|
|
46
|
+
* argument can be a registry version, a `workspace:*` spec, a `file:`/`link:`
|
|
47
|
+
* path, or a git URL. Dependency resolution is the package manager's job, not
|
|
48
|
+
* ours.
|
|
49
|
+
*/
|
|
50
|
+
export declare function runInstall(options: RunInstallOptions): RunInstallResult;
|
|
51
|
+
/**
|
|
52
|
+
* Parse one positional install argument into a `{ name, range }` pair.
|
|
53
|
+
*
|
|
54
|
+
* Handles the common forms (`name`, `name@range`, `@scope/name`,
|
|
55
|
+
* `@scope/name@range`), resolves `file:`/`link:` names from the target's
|
|
56
|
+
* `package.json`, and rejects git/URL specs that carry no package name (the
|
|
57
|
+
* user should add those to `package.json` directly, then re-run).
|
|
58
|
+
*/
|
|
59
|
+
export declare function parseSpec(raw: string, cwd: string): ParsedSpec;
|
|
60
|
+
/**
|
|
61
|
+
* Walk up from `startDir` to find the nearest workspace root that actually
|
|
62
|
+
* contains `startDir` as a member — a directory with a `pnpm-workspace.yaml`
|
|
63
|
+
* or a `package.json` `workspaces` field whose globs match `startDir`. Returns
|
|
64
|
+
* null when the project is standalone.
|
|
65
|
+
*/
|
|
66
|
+
export declare function findWorkspaceRoot(startDir: string): string | null;
|
|
67
|
+
/**
|
|
68
|
+
* Detect the package manager by the nearest lockfile, walking up from `dir`.
|
|
69
|
+
* Defaults to npm when nothing is found.
|
|
70
|
+
*/
|
|
71
|
+
export declare function detectPackageManager(dir: string): PackageManager;
|
|
72
|
+
//# sourceMappingURL=run-install.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-install.d.ts","sourceRoot":"","sources":["../../../src/install/run-install.ts"],"names":[],"mappings":"AAMA,6EAA6E;AAC7E,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAErD,8DAA8D;AAC9D,MAAM,WAAW,UAAU;IACzB,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,qEAAqE;IACrE,QAAQ,CAAC,G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