@decohere/create 0.0.1-dev.126 → 0.0.1-dev.16

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.
@@ -1,100 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get containerArgvFromHost () {
13
- return containerArgvFromHost;
14
- },
15
- get resolveLaunch () {
16
- return resolveLaunch;
17
- },
18
- get toProductArgv () {
19
- return toProductArgv;
20
- }
21
- });
22
- const _nodepath = require("node:path");
23
- const HOST_FLAGS_WITH_VALUE = new Set([
24
- "--config-file",
25
- "--log-level"
26
- ]);
27
- function toProductArgv(tokens) {
28
- if (tokens[0] === "webapi" && tokens[1] === "add") {
29
- return [
30
- "add",
31
- "api",
32
- ...tokens.slice(2)
33
- ];
34
- }
35
- if (tokens[0] === "webapi") {
36
- return [
37
- "create",
38
- "webapi",
39
- ...tokens.slice(1)
40
- ];
41
- }
42
- return tokens;
43
- }
44
- function containerArgvFromHost(argv) {
45
- const user = argv[0]?.includes("node") || argv[0]?.endsWith("node") ? argv.slice(2) : argv;
46
- const stripped = [];
47
- for(let i = 0; i < user.length; i++){
48
- const arg = user[i];
49
- if (arg != null && HOST_FLAGS_WITH_VALUE.has(arg)) {
50
- i++;
51
- continue;
52
- }
53
- if (arg != null) stripped.push(arg);
54
- }
55
- return toProductArgv(stripped);
56
- }
57
- function resolveLaunch(argv, cwd = process.cwd()) {
58
- if (argv.length === 1 && (argv[0] === "--help" || argv[0] === "-h" || argv[0] === "--version")) {
59
- return {
60
- targetDir: cwd,
61
- containerArgv: argv,
62
- projectName: (0, _nodepath.basename)(cwd),
63
- kind: "scaffold"
64
- };
65
- }
66
- let directoryFlag;
67
- const withoutD = [];
68
- for(let i = 0; i < argv.length; i++){
69
- const arg = argv[i];
70
- if (arg === "-d") {
71
- directoryFlag = argv[i + 1];
72
- i++;
73
- continue;
74
- }
75
- if (arg != null) withoutD.push(arg);
76
- }
77
- const product = toProductArgv(withoutD);
78
- const isAdd = product[0] === "add";
79
- let positional;
80
- let withoutPositional = product;
81
- if (!isAdd && product[0] === "create" && product[1] === "webapi" && product[2] != null && !product[2].startsWith("-")) {
82
- positional = product[2];
83
- withoutPositional = [
84
- product[0],
85
- product[1],
86
- ...product.slice(3)
87
- ];
88
- }
89
- const targetDir = (0, _nodepath.resolve)(cwd, positional?.trim() || directoryFlag?.trim() || ".");
90
- return {
91
- targetDir,
92
- containerArgv: [
93
- ...withoutPositional,
94
- "-d",
95
- "."
96
- ],
97
- projectName: (0, _nodepath.basename)(targetDir),
98
- kind: product[0] === "auth0" ? "auth0" : "scaffold"
99
- };
100
- }
@@ -1,105 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "runInBuilder", {
6
- enumerable: true,
7
- get: function() {
8
- return runInBuilder;
9
- }
10
- });
11
- const _nodechild_process = require("node:child_process");
12
- const _nodefs = require("node:fs");
13
- const _nodeos = require("node:os");
14
- const _nodepath = require("node:path");
15
- const _resolvelaunch = require("./resolve-launch.js");
16
- const _version = require("./version.js");
17
- const BUILDER_IMAGE = `${_version.CREATE_IMAGE_REPOSITORY}:${_version.CREATE_VERSION}`;
18
- function runInBuilder(argv) {
19
- const { targetDir, containerArgv, projectName, kind } = (0, _resolvelaunch.resolveLaunch)(argv);
20
- (0, _nodefs.mkdirSync)(targetDir, {
21
- recursive: true
22
- });
23
- if (kind === "scaffold") {
24
- (0, _nodefs.mkdirSync)((0, _nodepath.resolve)(targetDir, ".devcontainer", "npm-auth"), {
25
- recursive: true
26
- });
27
- }
28
- try {
29
- (0, _nodechild_process.execFileSync)("docker", [
30
- "info"
31
- ], {
32
- stdio: "pipe"
33
- });
34
- } catch {
35
- console.error("\n Docker is required to scaffold a Decohere project.\n" + " Install Docker Desktop: https://www.docker.com/products/docker-desktop\n");
36
- process.exit(1);
37
- }
38
- const hostUid = process.getuid?.();
39
- const hostGid = process.getgid?.() ?? hostUid;
40
- const runAsHostUser = hostUid != null && hostGid != null;
41
- const npmCacheDir = (0, _nodepath.resolve)((0, _nodeos.homedir)(), ".cache/decohere-create/npm");
42
- (0, _nodefs.mkdirSync)(npmCacheDir, {
43
- recursive: true
44
- });
45
- const builderHome = "/tmp/decohere-create-home";
46
- const volumes = [
47
- "-v",
48
- `${targetDir}:/workspace`,
49
- "-v",
50
- `${npmCacheDir}:/npm-cache`
51
- ];
52
- const envArgs = [
53
- "-e",
54
- "DECOHERE_BUILDER=1",
55
- "-e",
56
- `DECOHERE_PROJECT_NAME=${projectName}`,
57
- "-e",
58
- "NPM_CONFIG_CACHE=/npm-cache",
59
- "-e",
60
- "NPM_CONFIG_PREFER_OFFLINE=true",
61
- "-e",
62
- `HOME=${builderHome}`
63
- ];
64
- const npmrcPath = (0, _nodepath.resolve)((0, _nodeos.homedir)(), ".npmrc");
65
- if ((0, _nodefs.existsSync)(npmrcPath)) {
66
- volumes.push("-v", `${npmrcPath}:/tmp/host-npmrc:ro`);
67
- envArgs.push("-e", "NPM_CONFIG_USERCONFIG=/tmp/host-npmrc");
68
- }
69
- const auth0ConfigDir = (0, _nodepath.resolve)((0, _nodeos.homedir)(), ".config/auth0");
70
- (0, _nodefs.mkdirSync)(auth0ConfigDir, {
71
- recursive: true
72
- });
73
- volumes.push("-v", `${auth0ConfigDir}:${builderHome}/.config/auth0`);
74
- const userArgs = [];
75
- if (runAsHostUser) {
76
- userArgs.push("--user", `${hostUid}:${hostGid}`);
77
- } else if (hostUid != null) {
78
- envArgs.push("-e", `HOST_UID=${hostUid}`);
79
- if (hostGid != null) envArgs.push("-e", `HOST_GID=${hostGid}`);
80
- }
81
- console.log(kind === "auth0" ? " Running Auth0 CLI in the scaffolder image...\n" : " Running scaffolding in a sandboxed container...\n");
82
- const ttyFlags = process.stdin.isTTY ? [
83
- "-it"
84
- ] : [
85
- "-i"
86
- ];
87
- const result = (0, _nodechild_process.spawnSync)("docker", [
88
- "run",
89
- "--rm",
90
- ...ttyFlags,
91
- ...userArgs,
92
- ...volumes,
93
- ...envArgs,
94
- "-w",
95
- "/workspace",
96
- BUILDER_IMAGE,
97
- ...containerArgv
98
- ], {
99
- stdio: "inherit"
100
- });
101
- if (result.status === 0 && kind === "scaffold") {
102
- console.log(`\n Scaffold complete!\n\n Open your project:\n\n code ${targetDir}\n`);
103
- }
104
- process.exit(result.status ?? 0);
105
- }
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get CREATE_IMAGE_REPOSITORY () {
13
- return CREATE_IMAGE_REPOSITORY;
14
- },
15
- get CREATE_VERSION () {
16
- return CREATE_VERSION;
17
- }
18
- });
19
- const _nodemodule = require("node:module");
20
- const _nodepath = require("node:path");
21
- const _nodeurl = require("node:url");
22
- const _require = (0, _nodemodule.createRequire)(require("url").pathToFileURL(__filename).toString());
23
- const DEFAULT_CREATE_VERSION = "0.0.1-dev";
24
- const DEFAULT_CREATE_IMAGE_REPOSITORY = "ghcr.io/typesmiths/decohere/create";
25
- function resolveCreateMetadata() {
26
- let dir = (0, _nodepath.dirname)((0, _nodeurl.fileURLToPath)(require("url").pathToFileURL(__filename).toString()));
27
- for(let i = 0; i < 5; i++){
28
- try {
29
- const pkg = _require((0, _nodepath.join)(dir, "package.json"));
30
- if (pkg.name === "@decohere/create") {
31
- return {
32
- version: pkg.version ?? DEFAULT_CREATE_VERSION,
33
- imageRepository: pkg.decohere?.dockerImageRepository ?? DEFAULT_CREATE_IMAGE_REPOSITORY
34
- };
35
- }
36
- } catch {}
37
- const parent = (0, _nodepath.dirname)(dir);
38
- if (parent === dir) break;
39
- dir = parent;
40
- }
41
- return {
42
- version: DEFAULT_CREATE_VERSION,
43
- imageRepository: DEFAULT_CREATE_IMAGE_REPOSITORY
44
- };
45
- }
46
- const createMetadata = resolveCreateMetadata();
47
- const CREATE_VERSION = createMetadata.version;
48
- const CREATE_IMAGE_REPOSITORY = createMetadata.imageRepository;
package/es6/src/index.js DELETED
@@ -1,2 +0,0 @@
1
- export { containerArgvFromHost, resolveLaunch, toProductArgv } from "./resolve-launch.js";
2
- export { runInBuilder } from "./runner.js";
@@ -1,87 +0,0 @@
1
- import { basename, resolve } from "node:path";
2
- const HOST_FLAGS_WITH_VALUE = new Set([
3
- "--config-file",
4
- "--log-level"
5
- ]);
6
- /**
7
- * Map host / npm-create argv onto the product CLI (`create webapi` / `add api`).
8
- * `npm create @decohere webapi` already says “create”, so we prepend `create`
9
- * rather than making users type `create create webapi`.
10
- */ export function toProductArgv(tokens) {
11
- if (tokens[0] === "webapi" && tokens[1] === "add") {
12
- return [
13
- "add",
14
- "api",
15
- ...tokens.slice(2)
16
- ];
17
- }
18
- if (tokens[0] === "webapi") {
19
- return [
20
- "create",
21
- "webapi",
22
- ...tokens.slice(1)
23
- ];
24
- }
25
- return tokens;
26
- }
27
- export function containerArgvFromHost(argv) {
28
- const user = argv[0]?.includes("node") || argv[0]?.endsWith("node") ? argv.slice(2) : argv;
29
- const stripped = [];
30
- for(let i = 0; i < user.length; i++){
31
- const arg = user[i];
32
- if (arg != null && HOST_FLAGS_WITH_VALUE.has(arg)) {
33
- i++;
34
- continue;
35
- }
36
- if (arg != null) stripped.push(arg);
37
- }
38
- return toProductArgv(stripped);
39
- }
40
- /**
41
- * Host argv → directory to mount and argv for the in-image `decohere` entrypoint.
42
- * Positional `webapi my-app` / `create webapi my-app` wins over `-d` (npm treats `-d`
43
- * as its own loglevel).
44
- */ export function resolveLaunch(argv, cwd = process.cwd()) {
45
- if (argv.length === 1 && (argv[0] === "--help" || argv[0] === "-h" || argv[0] === "--version")) {
46
- return {
47
- targetDir: cwd,
48
- containerArgv: argv,
49
- projectName: basename(cwd),
50
- kind: "scaffold"
51
- };
52
- }
53
- let directoryFlag;
54
- const withoutD = [];
55
- for(let i = 0; i < argv.length; i++){
56
- const arg = argv[i];
57
- if (arg === "-d") {
58
- directoryFlag = argv[i + 1];
59
- i++;
60
- continue;
61
- }
62
- if (arg != null) withoutD.push(arg);
63
- }
64
- const product = toProductArgv(withoutD);
65
- const isAdd = product[0] === "add";
66
- let positional;
67
- let withoutPositional = product;
68
- if (!isAdd && product[0] === "create" && product[1] === "webapi" && product[2] != null && !product[2].startsWith("-")) {
69
- positional = product[2];
70
- withoutPositional = [
71
- product[0],
72
- product[1],
73
- ...product.slice(3)
74
- ];
75
- }
76
- const targetDir = resolve(cwd, positional?.trim() || directoryFlag?.trim() || ".");
77
- return {
78
- targetDir,
79
- containerArgv: [
80
- ...withoutPositional,
81
- "-d",
82
- "."
83
- ],
84
- projectName: basename(targetDir),
85
- kind: product[0] === "auth0" ? "auth0" : "scaffold"
86
- };
87
- }
package/es6/src/runner.js DELETED
@@ -1,98 +0,0 @@
1
- import { execFileSync, spawnSync } from "node:child_process";
2
- import { existsSync, mkdirSync } from "node:fs";
3
- import { homedir } from "node:os";
4
- import { resolve } from "node:path";
5
- import { resolveLaunch } from "./resolve-launch.js";
6
- import { CREATE_IMAGE_REPOSITORY, CREATE_VERSION } from "./version.js";
7
- const BUILDER_IMAGE = `${CREATE_IMAGE_REPOSITORY}:${CREATE_VERSION}`;
8
- /**
9
- * Pull/run the Decohere scaffolder image. Host `@decohere/create` does not load
10
- * the `@decohere/scaffold` dependency tree — that lives in the image only.
11
- */ export function runInBuilder(argv) {
12
- const { targetDir, containerArgv, projectName, kind } = resolveLaunch(argv);
13
- mkdirSync(targetDir, {
14
- recursive: true
15
- });
16
- if (kind === "scaffold") {
17
- mkdirSync(resolve(targetDir, ".devcontainer", "npm-auth"), {
18
- recursive: true
19
- });
20
- }
21
- try {
22
- execFileSync("docker", [
23
- "info"
24
- ], {
25
- stdio: "pipe"
26
- });
27
- } catch {
28
- console.error("\n Docker is required to scaffold a Decohere project.\n" + " Install Docker Desktop: https://www.docker.com/products/docker-desktop\n");
29
- process.exit(1);
30
- }
31
- const hostUid = process.getuid?.();
32
- const hostGid = process.getgid?.() ?? hostUid;
33
- const runAsHostUser = hostUid != null && hostGid != null;
34
- const npmCacheDir = resolve(homedir(), ".cache/decohere-create/npm");
35
- mkdirSync(npmCacheDir, {
36
- recursive: true
37
- });
38
- const builderHome = "/tmp/decohere-create-home";
39
- const volumes = [
40
- "-v",
41
- `${targetDir}:/workspace`,
42
- "-v",
43
- `${npmCacheDir}:/npm-cache`
44
- ];
45
- const envArgs = [
46
- "-e",
47
- "DECOHERE_BUILDER=1",
48
- "-e",
49
- `DECOHERE_PROJECT_NAME=${projectName}`,
50
- "-e",
51
- "NPM_CONFIG_CACHE=/npm-cache",
52
- "-e",
53
- "NPM_CONFIG_PREFER_OFFLINE=true",
54
- "-e",
55
- `HOME=${builderHome}`
56
- ];
57
- const npmrcPath = resolve(homedir(), ".npmrc");
58
- if (existsSync(npmrcPath)) {
59
- volumes.push("-v", `${npmrcPath}:/tmp/host-npmrc:ro`);
60
- envArgs.push("-e", "NPM_CONFIG_USERCONFIG=/tmp/host-npmrc");
61
- }
62
- const auth0ConfigDir = resolve(homedir(), ".config/auth0");
63
- mkdirSync(auth0ConfigDir, {
64
- recursive: true
65
- });
66
- volumes.push("-v", `${auth0ConfigDir}:${builderHome}/.config/auth0`);
67
- const userArgs = [];
68
- if (runAsHostUser) {
69
- userArgs.push("--user", `${hostUid}:${hostGid}`);
70
- } else if (hostUid != null) {
71
- envArgs.push("-e", `HOST_UID=${hostUid}`);
72
- if (hostGid != null) envArgs.push("-e", `HOST_GID=${hostGid}`);
73
- }
74
- console.log(kind === "auth0" ? " Running Auth0 CLI in the scaffolder image...\n" : " Running scaffolding in a sandboxed container...\n");
75
- const ttyFlags = process.stdin.isTTY ? [
76
- "-it"
77
- ] : [
78
- "-i"
79
- ];
80
- const result = spawnSync("docker", [
81
- "run",
82
- "--rm",
83
- ...ttyFlags,
84
- ...userArgs,
85
- ...volumes,
86
- ...envArgs,
87
- "-w",
88
- "/workspace",
89
- BUILDER_IMAGE,
90
- ...containerArgv
91
- ], {
92
- stdio: "inherit"
93
- });
94
- if (result.status === 0 && kind === "scaffold") {
95
- console.log(`\n Scaffold complete!\n\n Open your project:\n\n code ${targetDir}\n`);
96
- }
97
- process.exit(result.status ?? 0);
98
- }
@@ -1,30 +0,0 @@
1
- import { createRequire } from "node:module";
2
- import { dirname, join } from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- const _require = createRequire(import.meta.url);
5
- const DEFAULT_CREATE_VERSION = "0.0.1-dev";
6
- const DEFAULT_CREATE_IMAGE_REPOSITORY = "ghcr.io/typesmiths/decohere/create";
7
- function resolveCreateMetadata() {
8
- let dir = dirname(fileURLToPath(import.meta.url));
9
- for(let i = 0; i < 5; i++){
10
- try {
11
- const pkg = _require(join(dir, "package.json"));
12
- if (pkg.name === "@decohere/create") {
13
- return {
14
- version: pkg.version ?? DEFAULT_CREATE_VERSION,
15
- imageRepository: pkg.decohere?.dockerImageRepository ?? DEFAULT_CREATE_IMAGE_REPOSITORY
16
- };
17
- }
18
- } catch {}
19
- const parent = dirname(dir);
20
- if (parent === dir) break;
21
- dir = parent;
22
- }
23
- return {
24
- version: DEFAULT_CREATE_VERSION,
25
- imageRepository: DEFAULT_CREATE_IMAGE_REPOSITORY
26
- };
27
- }
28
- const createMetadata = resolveCreateMetadata();
29
- export const CREATE_VERSION = createMetadata.version;
30
- export const CREATE_IMAGE_REPOSITORY = createMetadata.imageRepository;
@@ -1,177 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Vendor `@decohere/scaffold` for the builder image: resolve `@decohere/*` from
4
- * dist/release via `file:` (not `overrides`), `npm install --install-links`,
5
- * then tar the installed tree including `node_modules`. `--install-links`
6
- * materializes `file:` packages (and their deps) instead of leaving symlinks
7
- * whose nested installs live outside the packed directory.
8
- */
9
- import { spawnSync } from "node:child_process";
10
- import { readdirSync, readFileSync, writeFileSync } from "node:fs";
11
- import { dirname, join, relative, resolve } from "node:path";
12
- import { fileURLToPath } from "node:url";
13
-
14
- /**
15
- * @typedef {{ name: string, dir: string }} WorkspacePackage
16
- */
17
-
18
- /**
19
- * @param {string} rootDir
20
- * @returns {WorkspacePackage[]}
21
- */
22
- export function collectWorkspacePackages(rootDir) {
23
- /** @type {WorkspacePackage[]} */
24
- const found = [];
25
- const walk = (dir) => {
26
- let entries;
27
- try {
28
- entries = readdirSync(dir, { withFileTypes: true });
29
- } catch {
30
- return;
31
- }
32
- for (const entry of entries) {
33
- if (entry.name === "node_modules" || entry.name === ".git") continue;
34
- const path = join(dir, entry.name);
35
- if (entry.isDirectory()) {
36
- walk(path);
37
- continue;
38
- }
39
- if (entry.name !== "package.json") continue;
40
- const pkg = JSON.parse(readFileSync(path, "utf8"));
41
- if (typeof pkg.name === "string" && pkg.name.startsWith("@decohere/")) {
42
- found.push({ name: pkg.name, dir });
43
- }
44
- }
45
- };
46
- walk(rootDir);
47
- return found;
48
- }
49
-
50
- /**
51
- * @param {string} fromDir
52
- * @param {string} pkgDir
53
- */
54
- export function fileSpec(fromDir, pkgDir) {
55
- let rel = relative(fromDir, pkgDir) || ".";
56
- rel = rel.replaceAll("\\", "/");
57
- if (!rel.startsWith(".")) rel = `./${rel}`;
58
- return `file:${rel}`;
59
- }
60
-
61
- /**
62
- * Rewrite `@decohere/*` dependency specs to local `file:` paths.
63
- * Must mutate `dependencies` (not `overrides`) — npm throws EOVERRIDE when an
64
- * override conflicts with a direct dependency.
65
- *
66
- * @param {Record<string, unknown>} pkg
67
- * @param {string} fromDir
68
- * @param {WorkspacePackage[]} packages
69
- */
70
- export function rewriteDecohereDepsToFile(pkg, fromDir, packages) {
71
- const byName = new Map(packages.map((item) => [item.name, item.dir]));
72
- const from = resolve(fromDir);
73
- const rewrite = (deps) => {
74
- if (deps == null || typeof deps !== "object" || Array.isArray(deps)) return deps;
75
- const next = { .../** @type {Record<string, unknown>} */ (deps) };
76
- for (const name of Object.keys(next)) {
77
- const dir = byName.get(name);
78
- if (dir == null || resolve(dir) === from) continue;
79
- next[name] = fileSpec(fromDir, dir);
80
- }
81
- return next;
82
- };
83
- return {
84
- ...pkg,
85
- dependencies: rewrite(pkg.dependencies),
86
- optionalDependencies: rewrite(pkg.optionalDependencies),
87
- };
88
- }
89
-
90
- function writeJson(path, value) {
91
- writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`);
92
- }
93
-
94
- function runNpm(cwd, args) {
95
- const result = spawnSync("npm", args, { cwd, encoding: "utf8" });
96
- if (result.status !== 0) {
97
- throw new Error(
98
- `npm ${args.join(" ")} failed (exit ${result.status}):\n${result.stderr}${result.stdout}`,
99
- );
100
- }
101
- return result.stdout.trim();
102
- }
103
-
104
- function packInstalledTree(outDir, dest) {
105
- const result = spawnSync(
106
- "tar",
107
- ["--create", "--gzip", "--dereference", "--file", dest, "-C", outDir, "."],
108
- { encoding: "utf8" },
109
- );
110
- if (result.status !== 0) {
111
- throw new Error(`tar failed (exit ${result.status}):\n${result.stderr}${result.stdout}`);
112
- }
113
- }
114
-
115
- export function packBuilderTgz(options) {
116
- const outDir = resolve(options.outDir);
117
- const workspaceOut = resolve(options.workspaceOut);
118
- const dest = resolve(options.dest);
119
- const packageJsonPath = join(outDir, "package.json");
120
- const packages = collectWorkspacePackages(workspaceOut);
121
- const originals = packages.map((pkg) => {
122
- const path = join(pkg.dir, "package.json");
123
- return { path, original: JSON.parse(readFileSync(path, "utf8")) };
124
- });
125
- const createOriginal = originals.find((entry) => entry.path === packageJsonPath)?.original;
126
- if (createOriginal == null) {
127
- throw new Error(`No @decohere package.json at ${packageJsonPath}`);
128
- }
129
-
130
- try {
131
- for (const { path, original } of originals) {
132
- writeJson(path, rewriteDecohereDepsToFile(original, dirname(path), packages));
133
- }
134
- runNpm(outDir, ["install", "--omit=dev", "--ignore-scripts", "--install-links"]);
135
- } finally {
136
- for (const { path, original } of originals) {
137
- writeJson(path, original);
138
- }
139
- }
140
-
141
- packInstalledTree(outDir, dest);
142
- return dest;
143
- }
144
-
145
- function parseArgs(argv) {
146
- /** @type {Record<string, string>} */
147
- const parsed = {};
148
- for (let i = 0; i < argv.length; i++) {
149
- const arg = argv[i];
150
- if (arg == null || !arg.startsWith("--")) continue;
151
- const key = arg.slice(2);
152
- const value = argv[i + 1];
153
- if (value == null || value.startsWith("--")) {
154
- throw new Error(`Missing value for --${key}`);
155
- }
156
- parsed[key] = value;
157
- i++;
158
- }
159
- return parsed;
160
- }
161
-
162
- function main() {
163
- const args = parseArgs(process.argv.slice(2));
164
- const outDir = args["out-dir"];
165
- const workspaceOut = args["workspace-out"];
166
- const dest = args.dest;
167
- if (outDir == null || workspaceOut == null || dest == null) {
168
- throw new Error(
169
- "Usage: pack-builder-tgz.mjs --out-dir <dir> --workspace-out <dir> --dest <create.tgz>",
170
- );
171
- }
172
- packBuilderTgz({ outDir, workspaceOut, dest });
173
- }
174
-
175
- if (process.argv[1] != null && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
176
- main();
177
- }
@@ -1,3 +0,0 @@
1
- export type { LaunchKind, LaunchPlan } from "./resolve-launch.js";
2
- export { containerArgvFromHost, resolveLaunch, toProductArgv } from "./resolve-launch.js";
3
- export { runInBuilder } from "./runner.js";
@@ -1,20 +0,0 @@
1
- export type LaunchKind = "scaffold" | "auth0";
2
- export type LaunchPlan = {
3
- targetDir: string;
4
- containerArgv: string[];
5
- projectName: string;
6
- kind: LaunchKind;
7
- };
8
- /**
9
- * Map host / npm-create argv onto the product CLI (`create webapi` / `add api`).
10
- * `npm create @decohere webapi` already says “create”, so we prepend `create`
11
- * rather than making users type `create create webapi`.
12
- */
13
- export declare function toProductArgv(tokens: string[]): string[];
14
- export declare function containerArgvFromHost(argv: string[]): string[];
15
- /**
16
- * Host argv → directory to mount and argv for the in-image `decohere` entrypoint.
17
- * Positional `webapi my-app` / `create webapi my-app` wins over `-d` (npm treats `-d`
18
- * as its own loglevel).
19
- */
20
- export declare function resolveLaunch(argv: string[], cwd?: string): LaunchPlan;
@@ -1,5 +0,0 @@
1
- /**
2
- * Pull/run the Decohere scaffolder image. Host `@decohere/create` does not load
3
- * the `@decohere/scaffold` dependency tree — that lives in the image only.
4
- */
5
- export declare function runInBuilder(argv: string[]): never;
@@ -1,2 +0,0 @@
1
- export declare const CREATE_VERSION: string;
2
- export declare const CREATE_IMAGE_REPOSITORY: string;