@decohere/create 0.0.1-dev.48 → 0.0.1-dev.5
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/commonjs/src/cli.js +9 -3
- package/commonjs/src/scaffold.js +48 -0
- package/commonjs/src/templates.js +64 -0
- package/es6/src/cli.js +9 -3
- package/es6/src/scaffold.js +38 -0
- package/es6/src/templates.js +40 -0
- package/package.json +3 -8
- package/types/src/scaffold.d.ts +4 -0
- package/types/src/templates.d.ts +4 -0
- package/commonjs/src/domain/prompt.js +0 -64
- package/commonjs/src/models/compose.model.js +0 -138
- package/commonjs/src/models/config-yaml.model.js +0 -88
- package/commonjs/src/models/const.js +0 -31
- package/commonjs/src/models/dev-container.model.js +0 -100
- package/commonjs/src/models/docker-image.model.js +0 -221
- package/commonjs/src/models/env-file.model.js +0 -47
- package/commonjs/src/models/gitignore.model.js +0 -31
- package/commonjs/src/models/launch-json.model.js +0 -74
- package/commonjs/src/models/package-json.model.js +0 -133
- package/commonjs/src/models/project.model.js +0 -134
- package/commonjs/src/models/source-file.js +0 -6
- package/commonjs/src/models/tsconfig.model.js +0 -34
- package/commonjs/src/models/vscode-settings.model.js +0 -31
- package/commonjs/src/program.js +0 -135
- package/commonjs/src/resolve-target-dir.js +0 -19
- package/commonjs/src/runner.js +0 -144
- package/commonjs/src/services/scaffold.service.js +0 -62
- package/commonjs/src/version.js +0 -50
- package/commonjs/src/webapi/api-name.js +0 -95
- package/commonjs/src/webapi/const.js +0 -50
- package/commonjs/src/webapi/create-api.js +0 -285
- package/commonjs/src/webapi/features/auth.feature.js +0 -463
- package/commonjs/src/webapi/features/auth0-cli.js +0 -406
- package/commonjs/src/webapi/features/biome-format.js +0 -49
- package/commonjs/src/webapi/features/database.feature.js +0 -273
- package/commonjs/src/webapi/features/finalize.feature.js +0 -91
- package/commonjs/src/webapi/features/postman.feature.js +0 -319
- package/commonjs/src/webapi/models/api-package-json.model.js +0 -63
- package/commonjs/src/webapi/models/auth-config.model.js +0 -26
- package/commonjs/src/webapi/models/controller-source-file.model.js +0 -188
- package/commonjs/src/webapi/models/github-ci.model.js +0 -193
- package/commonjs/src/webapi/models/main-source-file.model.js +0 -165
- package/commonjs/src/webapi/models/production-dockerfile.model.js +0 -138
- package/commonjs/src/webapi/models/sample-files.model.js +0 -60
- package/commonjs/src/webapi/models/webapi-image.model.js +0 -22
- package/commonjs/src/webapi/postman/hello-openapi.js +0 -175
- package/commonjs/src/webapi/postman/local-view.js +0 -184
- package/commonjs/src/webapi/postman/openapi-to-postman.js +0 -202
- package/es6/src/domain/prompt.js +0 -43
- package/es6/src/models/compose.model.js +0 -132
- package/es6/src/models/config-yaml.model.js +0 -76
- package/es6/src/models/const.js +0 -21
- package/es6/src/models/dev-container.model.js +0 -90
- package/es6/src/models/docker-image.model.js +0 -185
- package/es6/src/models/env-file.model.js +0 -43
- package/es6/src/models/gitignore.model.js +0 -21
- package/es6/src/models/launch-json.model.js +0 -64
- package/es6/src/models/package-json.model.js +0 -129
- package/es6/src/models/project.model.js +0 -119
- package/es6/src/models/source-file.js +0 -3
- package/es6/src/models/tsconfig.model.js +0 -24
- package/es6/src/models/vscode-settings.model.js +0 -21
- package/es6/src/program.js +0 -76
- package/es6/src/resolve-target-dir.js +0 -9
- package/es6/src/runner.js +0 -146
- package/es6/src/services/scaffold.service.js +0 -52
- package/es6/src/version.js +0 -32
- package/es6/src/webapi/api-name.js +0 -59
- package/es6/src/webapi/const.js +0 -20
- package/es6/src/webapi/create-api.js +0 -265
- package/es6/src/webapi/features/auth.feature.js +0 -412
- package/es6/src/webapi/features/auth0-cli.js +0 -348
- package/es6/src/webapi/features/biome-format.js +0 -42
- package/es6/src/webapi/features/database.feature.js +0 -263
- package/es6/src/webapi/features/finalize.feature.js +0 -81
- package/es6/src/webapi/features/postman.feature.js +0 -253
- package/es6/src/webapi/models/api-package-json.model.js +0 -58
- package/es6/src/webapi/models/auth-config.model.js +0 -22
- package/es6/src/webapi/models/controller-source-file.model.js +0 -179
- package/es6/src/webapi/models/github-ci.model.js +0 -186
- package/es6/src/webapi/models/main-source-file.model.js +0 -161
- package/es6/src/webapi/models/production-dockerfile.model.js +0 -126
- package/es6/src/webapi/models/sample-files.model.js +0 -42
- package/es6/src/webapi/models/webapi-image.model.js +0 -12
- package/es6/src/webapi/postman/hello-openapi.js +0 -168
- package/es6/src/webapi/postman/local-view.js +0 -169
- package/es6/src/webapi/postman/openapi-to-postman.js +0 -179
- package/pack-builder-tgz.mjs +0 -177
- package/types/src/domain/prompt.d.ts +0 -4
- package/types/src/models/compose.model.d.ts +0 -59
- package/types/src/models/config-yaml.model.d.ts +0 -27
- package/types/src/models/const.d.ts +0 -19
- package/types/src/models/dev-container.model.d.ts +0 -33
- package/types/src/models/docker-image.model.d.ts +0 -56
- package/types/src/models/env-file.model.d.ts +0 -15
- package/types/src/models/gitignore.model.d.ts +0 -6
- package/types/src/models/launch-json.model.d.ts +0 -7
- package/types/src/models/package-json.model.d.ts +0 -32
- package/types/src/models/project.model.d.ts +0 -60
- package/types/src/models/source-file.d.ts +0 -11
- package/types/src/models/tsconfig.model.d.ts +0 -5
- package/types/src/models/vscode-settings.model.d.ts +0 -7
- package/types/src/program.d.ts +0 -3
- package/types/src/resolve-target-dir.d.ts +0 -5
- package/types/src/runner.d.ts +0 -15
- package/types/src/services/scaffold.service.d.ts +0 -22
- package/types/src/version.d.ts +0 -4
- package/types/src/webapi/api-name.d.ts +0 -14
- package/types/src/webapi/const.d.ts +0 -17
- package/types/src/webapi/create-api.d.ts +0 -15
- package/types/src/webapi/features/auth.feature.d.ts +0 -10
- package/types/src/webapi/features/auth0-cli.d.ts +0 -72
- package/types/src/webapi/features/biome-format.d.ts +0 -5
- package/types/src/webapi/features/database.feature.d.ts +0 -5
- package/types/src/webapi/features/finalize.feature.d.ts +0 -2
- package/types/src/webapi/features/postman.feature.d.ts +0 -16
- package/types/src/webapi/models/api-package-json.model.d.ts +0 -18
- package/types/src/webapi/models/auth-config.model.d.ts +0 -26
- package/types/src/webapi/models/controller-source-file.model.d.ts +0 -45
- package/types/src/webapi/models/github-ci.model.d.ts +0 -9
- package/types/src/webapi/models/main-source-file.model.d.ts +0 -54
- package/types/src/webapi/models/production-dockerfile.model.d.ts +0 -20
- package/types/src/webapi/models/sample-files.model.d.ts +0 -7
- package/types/src/webapi/models/webapi-image.model.d.ts +0 -5
- package/types/src/webapi/postman/hello-openapi.d.ts +0 -19
- package/types/src/webapi/postman/local-view.d.ts +0 -17
- package/types/src/webapi/postman/openapi-to-postman.d.ts +0 -62
package/pack-builder-tgz.mjs
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Vendor `@decohere/create` 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 create 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,4 +0,0 @@
|
|
|
1
|
-
/** Release stdin so the process can exit after interactive prompts. */
|
|
2
|
-
export declare function closePrompt(): void;
|
|
3
|
-
export declare function ask(question: string, fallback?: string): Promise<string>;
|
|
4
|
-
export declare function pick<T>(label: string, items: T[], display: (item: T) => string): Promise<T | null>;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { KeyedModel } from "./source-file.js";
|
|
2
|
-
export type ComposeNetworkRef = string | {
|
|
3
|
-
/** Network key under `networks:` on this service */
|
|
4
|
-
[networkKey: string]: {
|
|
5
|
-
aliases?: string[];
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export interface ComposeHealthcheck {
|
|
9
|
-
test: string[];
|
|
10
|
-
interval?: string;
|
|
11
|
-
timeout?: string;
|
|
12
|
-
retries?: number;
|
|
13
|
-
}
|
|
14
|
-
export interface ComposeService {
|
|
15
|
-
build?: string;
|
|
16
|
-
image?: string;
|
|
17
|
-
container_name?: string;
|
|
18
|
-
env_file?: string[];
|
|
19
|
-
environment?: Record<string, string>;
|
|
20
|
-
ports?: string[];
|
|
21
|
-
volumes?: string[];
|
|
22
|
-
command?: string;
|
|
23
|
-
restart?: string;
|
|
24
|
-
depends_on?: string[];
|
|
25
|
-
/** Compose profiles (service only starts when profile is enabled). */
|
|
26
|
-
profiles?: string[];
|
|
27
|
-
/** Attach to compose networks (string name or map with aliases). */
|
|
28
|
-
networks?: ComposeNetworkRef[];
|
|
29
|
-
healthcheck?: ComposeHealthcheck;
|
|
30
|
-
}
|
|
31
|
-
export type ComposeNetwork = {
|
|
32
|
-
/** Fixed Docker network name (shareable across compose projects). */
|
|
33
|
-
name: string;
|
|
34
|
-
external?: boolean;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Live builder for `docker-compose.yml`.
|
|
38
|
-
*
|
|
39
|
-
* Features call `addService` / `addVolume` / `addNetwork` in their scaffold phases.
|
|
40
|
-
*/
|
|
41
|
-
export declare class DockerCompose implements KeyedModel {
|
|
42
|
-
readonly key: string;
|
|
43
|
-
private _projectName;
|
|
44
|
-
private readonly _services;
|
|
45
|
-
private readonly _volumes;
|
|
46
|
-
private readonly _networks;
|
|
47
|
-
/** Compose project name (`name:` top-level) — isolates containers/volumes. */
|
|
48
|
-
setProjectName(name: string): this;
|
|
49
|
-
addService(name: string, config: ComposeService): this;
|
|
50
|
-
files(): {
|
|
51
|
-
filePath: string;
|
|
52
|
-
content: string;
|
|
53
|
-
}[];
|
|
54
|
-
addVolume(name: string): this;
|
|
55
|
-
addNetwork(key: string, network: ComposeNetwork): this;
|
|
56
|
-
/** Append an env_file path to an existing service. */
|
|
57
|
-
addEnvFile(serviceName: string, filePath: string): this;
|
|
58
|
-
getContent(): string;
|
|
59
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { KeyedModel, SourceFile } from "./source-file.js";
|
|
2
|
-
/**
|
|
3
|
-
* Builder for a YAML config file (e.g. config/config.yaml or config/config.dev.yaml).
|
|
4
|
-
*
|
|
5
|
-
* Starts with a base section passed to the constructor. Features call
|
|
6
|
-
* `addSection(yaml)` during their scaffold phase to append their own block.
|
|
7
|
-
* `files()` joins all sections with a blank line separator.
|
|
8
|
-
*/
|
|
9
|
-
export declare class ConfigYaml implements KeyedModel {
|
|
10
|
-
readonly key: string;
|
|
11
|
-
private readonly filePath;
|
|
12
|
-
private readonly _sections;
|
|
13
|
-
constructor(key: string, filePath: string, baseContent: string);
|
|
14
|
-
addSection(yaml: string): this;
|
|
15
|
-
/** True when a datasource with this `name:` already appears in the file. */
|
|
16
|
-
hasDataSource(name: string): boolean;
|
|
17
|
-
hasDataSources(): boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Insert a `dataSources` list item. Used by `webapi add` so we do not write a
|
|
20
|
-
* second top-level `database:` key (YAML last-key-wins).
|
|
21
|
-
*/
|
|
22
|
-
appendDataSource(item: string): this;
|
|
23
|
-
static fromFile(key: string, relativePath: string, absolutePath: string): ConfigYaml;
|
|
24
|
-
files(): SourceFile[];
|
|
25
|
-
}
|
|
26
|
-
/** Insert a YAML list item under `dataSources:`; append a new `database:` block if missing. */
|
|
27
|
-
export declare function injectYamlDataSource(yaml: string, item: string): string;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare const WELL_KNOWN_FILES: {
|
|
2
|
-
VSCODE_SETTINGS: string;
|
|
3
|
-
LAUNCH_JSON: string;
|
|
4
|
-
DOCKER_COMPOSE: string;
|
|
5
|
-
DEVCONTAINER_JSON: string;
|
|
6
|
-
DOCKERFILE: string;
|
|
7
|
-
PRODUCTION_DOCKERFILE: string;
|
|
8
|
-
GITHUB_CI: string;
|
|
9
|
-
PACKAGE_JSON: string;
|
|
10
|
-
API_PACKAGE_JSON: string;
|
|
11
|
-
TSCONFIG: string;
|
|
12
|
-
MAIN_TS: string;
|
|
13
|
-
CONTROLLER_TS: string;
|
|
14
|
-
CONFIG_YAML: string;
|
|
15
|
-
CONFIG_DEV_YAML: string;
|
|
16
|
-
GITIGNORE: string;
|
|
17
|
-
AUTH_CONFIG: string;
|
|
18
|
-
ENV_FILE: string;
|
|
19
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { KeyedModel, SourceFile } from "./source-file.js";
|
|
2
|
-
/**
|
|
3
|
-
* Model for `.devcontainer/devcontainer.json`.
|
|
4
|
-
*
|
|
5
|
-
* Features call builder methods (`addExtension`, `forwardPort`, etc.) during
|
|
6
|
-
* their configure phase. `MonoRepoScaffold` calls `files()` at render time.
|
|
7
|
-
*/
|
|
8
|
-
export type PortAttributes = {
|
|
9
|
-
label?: string;
|
|
10
|
-
/** When true, host port must match the container port (no random remap). */
|
|
11
|
-
requireLocalPort?: boolean;
|
|
12
|
-
onAutoForward?: "notify" | "openBrowser" | "openPreview" | "silent" | "ignore";
|
|
13
|
-
};
|
|
14
|
-
export declare class DevContainer implements KeyedModel {
|
|
15
|
-
readonly key: string;
|
|
16
|
-
private readonly _extensions;
|
|
17
|
-
private readonly _ports;
|
|
18
|
-
private readonly _portAttributes;
|
|
19
|
-
private readonly _mounts;
|
|
20
|
-
private _postStartCommand?;
|
|
21
|
-
private _initializeCommand?;
|
|
22
|
-
private _remoteUser;
|
|
23
|
-
private _useCompose;
|
|
24
|
-
constructor();
|
|
25
|
-
addExtension(...ids: string[]): this;
|
|
26
|
-
forwardPort(...ports: number[]): this;
|
|
27
|
-
setPortAttributes(port: number, attrs: PortAttributes): this;
|
|
28
|
-
setPostStartCommand(cmd: string): this;
|
|
29
|
-
setInitializeCommand(cmd: string): this;
|
|
30
|
-
setRemoteUser(user: string): this;
|
|
31
|
-
useCompose(): this;
|
|
32
|
-
files(): SourceFile[];
|
|
33
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { KeyedModel, SourceFile } from "./source-file.js";
|
|
2
|
-
export type LayerWriter = (dockerfile: DockerfileModel) => void;
|
|
3
|
-
export declare class DockerStep {
|
|
4
|
-
readonly key: string;
|
|
5
|
-
readonly content: string;
|
|
6
|
-
readonly order: number;
|
|
7
|
-
constructor(key: string, content: string, order?: number);
|
|
8
|
-
static run(key: string, command: string, order?: number): DockerStep;
|
|
9
|
-
static raw(key: string, content: string, order?: number): DockerStep;
|
|
10
|
-
static entrypoint(key: string, value: string | readonly string[], order?: number): DockerStep;
|
|
11
|
-
}
|
|
12
|
-
export declare function withCommandHistory(options?: {
|
|
13
|
-
historyDir?: string;
|
|
14
|
-
historyFileName?: string;
|
|
15
|
-
order?: number;
|
|
16
|
-
}): LayerWriter;
|
|
17
|
-
export declare function withNodeUser(options?: {
|
|
18
|
-
username?: string;
|
|
19
|
-
includeUserInstruction?: boolean;
|
|
20
|
-
order?: number;
|
|
21
|
-
}): LayerWriter;
|
|
22
|
-
export declare function withPnpm(options?: {
|
|
23
|
-
version?: string;
|
|
24
|
-
usernameExpr?: string;
|
|
25
|
-
order?: number;
|
|
26
|
-
}): LayerWriter;
|
|
27
|
-
export declare function withWorkspaceNodeModulesOwnership(options?: {
|
|
28
|
-
workspaceDir?: string;
|
|
29
|
-
usernameExpr?: string;
|
|
30
|
-
order?: number;
|
|
31
|
-
}): LayerWriter;
|
|
32
|
-
export declare function withVsCodeJsDebugBootloaderFix(options?: {
|
|
33
|
-
bashrcPath?: string;
|
|
34
|
-
order?: number;
|
|
35
|
-
}): LayerWriter;
|
|
36
|
-
export declare class DockerfileModel implements KeyedModel {
|
|
37
|
-
readonly key: string;
|
|
38
|
-
private readonly _steps;
|
|
39
|
-
private readonly _layerWriters;
|
|
40
|
-
private _fromImage;
|
|
41
|
-
private _layerCounter;
|
|
42
|
-
constructor(baseImage: string);
|
|
43
|
-
from(baseImage: string): this;
|
|
44
|
-
addLayer(layer: LayerWriter | string, order?: 5000): this;
|
|
45
|
-
addStep(step: DockerStep): this;
|
|
46
|
-
removeStep(key: string): this;
|
|
47
|
-
entrypoint(value: string | readonly string[], order?: 10000): this;
|
|
48
|
-
addRunStep(cmd: string): this;
|
|
49
|
-
build(): string;
|
|
50
|
-
protected registerBaseLayers(): void;
|
|
51
|
-
files(): SourceFile[];
|
|
52
|
-
}
|
|
53
|
-
export declare class DevContainerImageModel extends DockerfileModel {
|
|
54
|
-
protected registerBaseLayers(): void;
|
|
55
|
-
files(): SourceFile[];
|
|
56
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { KeyedModel, SourceFile } from "./source-file.js";
|
|
2
|
-
/**
|
|
3
|
-
* Accumulates key=value pairs and renders them as a `.env` file.
|
|
4
|
-
*
|
|
5
|
-
* Register once in the workspace; features call `addEntry` during their
|
|
6
|
-
* scaffold phase to contribute environment variables. The final file is
|
|
7
|
-
* written at render time when `workspace.scaffold()` is called.
|
|
8
|
-
*/
|
|
9
|
-
export declare class EnvFile implements KeyedModel {
|
|
10
|
-
readonly key: string;
|
|
11
|
-
private readonly _entries;
|
|
12
|
-
addEntry(key: string, value: string): this;
|
|
13
|
-
static fromFile(absolutePath: string): EnvFile;
|
|
14
|
-
files(): SourceFile[];
|
|
15
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { KeyedModel, SourceFile } from "./source-file.js";
|
|
2
|
-
export type PackageJsonOptions = {
|
|
3
|
-
startEntry?: string;
|
|
4
|
-
/** API slugs in this workspace. Drives `start:<name>` / `dev:<name>`. */
|
|
5
|
-
apiNames?: readonly string[];
|
|
6
|
-
/** Host workspace name used in `@<workspace>/<api>` for flux `--project`. */
|
|
7
|
-
workspaceName?: string;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Builder for the root `package.json`.
|
|
11
|
-
*
|
|
12
|
-
* Starts with the core API dependencies. Features call `addDependency` /
|
|
13
|
-
* `addDevDependency` during their scaffold phase to inject their own deps
|
|
14
|
-
* before `files()` is called at render time.
|
|
15
|
-
*/
|
|
16
|
-
export declare class PackageJson implements KeyedModel {
|
|
17
|
-
private readonly name;
|
|
18
|
-
readonly key: string;
|
|
19
|
-
private _dependencies;
|
|
20
|
-
private _devDependencies;
|
|
21
|
-
private _scripts;
|
|
22
|
-
private _version;
|
|
23
|
-
private _type;
|
|
24
|
-
private _rest;
|
|
25
|
-
constructor(name: string, options?: PackageJsonOptions);
|
|
26
|
-
/** Load an existing root package.json so `webapi add` can merge scripts/deps. */
|
|
27
|
-
static fromFile(filePath: string): PackageJson;
|
|
28
|
-
addDependency(name: string, version: string): this;
|
|
29
|
-
addDevDependency(name: string, version: string): this;
|
|
30
|
-
addScript(name: string, command: string): this;
|
|
31
|
-
files(): SourceFile[];
|
|
32
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { KeyedModel, SourceFile, SourceFileProvider } from "./source-file.js";
|
|
2
|
-
/**
|
|
3
|
-
* A sub-unit of the monorepo (e.g. `projects/api`).
|
|
4
|
-
*
|
|
5
|
-
* Models and files registered here produce paths relative to `dir`. The parent
|
|
6
|
-
* `MonoRepoScaffold` calls `files()` and prepends `dir/` to every path, so
|
|
7
|
-
* models remain unaware of where they live in the repo.
|
|
8
|
-
*/
|
|
9
|
-
export declare class ProjectScaffold {
|
|
10
|
-
readonly dir: string;
|
|
11
|
-
private readonly _models;
|
|
12
|
-
private readonly _files;
|
|
13
|
-
constructor(dir: string);
|
|
14
|
-
addModel<T extends KeyedModel>(model: T): T;
|
|
15
|
-
addFile(provider: SourceFileProvider): this;
|
|
16
|
-
getModel<T extends SourceFileProvider>(key: string): T | undefined;
|
|
17
|
-
getModels<T extends SourceFileProvider>(ctor: new (...args: never[]) => T): T[];
|
|
18
|
-
/** Returns all files with `dir/` prepended to each path. */
|
|
19
|
-
files(): SourceFile[];
|
|
20
|
-
}
|
|
21
|
-
export declare abstract class WorkspaceScaffold {
|
|
22
|
-
readonly files: SourceFile[];
|
|
23
|
-
targetDir: string;
|
|
24
|
-
private _name;
|
|
25
|
-
/** Project name — host directory basename, not the in-container mount path. */
|
|
26
|
-
get name(): string;
|
|
27
|
-
setName(name: string): this;
|
|
28
|
-
/** Add an ad-hoc file provider whose output is included at render time. */
|
|
29
|
-
addFile(provider: SourceFileProvider): this;
|
|
30
|
-
abstract addModel<T extends KeyedModel>(model: T): T;
|
|
31
|
-
abstract getModel<T extends SourceFileProvider>(key: string): T | undefined;
|
|
32
|
-
abstract getModels<T extends SourceFileProvider>(ctor: new (...args: never[]) => T): T[];
|
|
33
|
-
abstract getProject(dir: string): ProjectScaffold | undefined;
|
|
34
|
-
abstract getProjects(): readonly ProjectScaffold[];
|
|
35
|
-
abstract scaffold(): Promise<void> | void;
|
|
36
|
-
}
|
|
37
|
-
export declare class MonoRepoScaffold extends WorkspaceScaffold {
|
|
38
|
-
private readonly _models;
|
|
39
|
-
private readonly _projects;
|
|
40
|
-
/** Register a named project. */
|
|
41
|
-
addProject(project: ProjectScaffold): ProjectScaffold;
|
|
42
|
-
/** Retrieve a previously-registered project by its directory path. */
|
|
43
|
-
getProject(dir: string): ProjectScaffold | undefined;
|
|
44
|
-
/** All registered projects, in registration order. */
|
|
45
|
-
getProjects(): readonly ProjectScaffold[];
|
|
46
|
-
/** Register a named model at workspace level. */
|
|
47
|
-
addModel<T extends KeyedModel>(model: T): T;
|
|
48
|
-
/**
|
|
49
|
-
* Retrieve a model by key. Searches workspace models first, then all
|
|
50
|
-
* registered projects in order.
|
|
51
|
-
*/
|
|
52
|
-
getModel<T extends SourceFileProvider>(key: string): T | undefined;
|
|
53
|
-
/**
|
|
54
|
-
* Retrieve all models of a given type. Searches workspace models and all
|
|
55
|
-
* projects, so features can discover controllers across multiple projects.
|
|
56
|
-
*/
|
|
57
|
-
getModels<T extends SourceFileProvider>(ctor: new (...args: never[]) => T): T[];
|
|
58
|
-
/** Render all models and projects into files, then write everything to disk. */
|
|
59
|
-
scaffold(): Promise<void>;
|
|
60
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export interface SourceFileProvider {
|
|
2
|
-
files(): SourceFile[];
|
|
3
|
-
}
|
|
4
|
-
/** A SourceFileProvider that knows its own registration key. */
|
|
5
|
-
export interface KeyedModel extends SourceFileProvider {
|
|
6
|
-
readonly key: string;
|
|
7
|
-
}
|
|
8
|
-
export type SourceFile = {
|
|
9
|
-
filePath: string;
|
|
10
|
-
content: string;
|
|
11
|
-
};
|
package/types/src/program.d.ts
DELETED
package/types/src/runner.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ApiOptions } from "./webapi/create-api.js";
|
|
2
|
-
/**
|
|
3
|
-
* Run the scaffold inside a pre-built Docker builder image.
|
|
4
|
-
*
|
|
5
|
-
* Called when `DECOHERE_BUILDER` is not set — i.e. the CLI is running on the
|
|
6
|
-
* host, outside the container. Mounts the target directory as `/workspace` so
|
|
7
|
-
* the scaffolded files are written back to the host filesystem.
|
|
8
|
-
*
|
|
9
|
-
* The container runs as the host uid/gid whenever possible so scaffolded files
|
|
10
|
-
* are never root-owned (post-hoc `chown` is unreliable across Docker setups).
|
|
11
|
-
*
|
|
12
|
-
* Host `~/.config/auth0` is mounted when present so the Auth0 CLI can reuse
|
|
13
|
-
* credentials (required for Postman SPA / auth0ClientId).
|
|
14
|
-
*/
|
|
15
|
-
export declare function runInBuilder(opts: ApiOptions): never;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { WorkspaceScaffold } from "../models/project.model.js";
|
|
2
|
-
/**
|
|
3
|
-
* A feature has three responsibilities:
|
|
4
|
-
* 1. `getOptions` — resolve provider selection and any follow-up questions.
|
|
5
|
-
* Receives the options collected so far; returns only the keys it owns.
|
|
6
|
-
* Short-circuits if the caller already supplied those keys via CLI flags.
|
|
7
|
-
* 2. `scaffold` — mutate the workspace models and/or write files using the
|
|
8
|
-
* fully-resolved options. Called after ALL features have gathered options
|
|
9
|
-
* but BEFORE files are written to disk.
|
|
10
|
-
* 3. `finalize` (optional) — run post-write actions (e.g. install dependencies).
|
|
11
|
-
* Called after workspace.scaffold() has flushed all files to disk.
|
|
12
|
-
*/
|
|
13
|
-
export interface Feature<TOptions extends object = object> {
|
|
14
|
-
getOptions(workspace: WorkspaceScaffold, cliOptions: Partial<TOptions>): Promise<Partial<TOptions>>;
|
|
15
|
-
scaffold(workspace: WorkspaceScaffold, options: TOptions): Promise<void> | void;
|
|
16
|
-
finalize?(workspace: WorkspaceScaffold, options: TOptions): Promise<void> | void;
|
|
17
|
-
}
|
|
18
|
-
declare function scaffold(workspace: WorkspaceScaffold, cliOptions: object, features: Feature[]): Promise<void>;
|
|
19
|
-
export declare const ScaffoldService: {
|
|
20
|
-
scaffold: typeof scaffold;
|
|
21
|
-
};
|
|
22
|
-
export {};
|
package/types/src/version.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/** Version of @decohere/create, used to pin scaffolded @decohere/* dependencies. */
|
|
2
|
-
export declare const CREATE_VERSION: string;
|
|
3
|
-
/** Canonical published Docker repository for the @decohere/create builder image. */
|
|
4
|
-
export declare const CREATE_IMAGE_REPOSITORY: string;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/** Lowercase npm-safe directory slug: `billing`, `admin-api`. */
|
|
2
|
-
export declare const API_NAME_PATTERN: RegExp;
|
|
3
|
-
export declare class CreateCliError extends Error {
|
|
4
|
-
constructor(message: string);
|
|
5
|
-
}
|
|
6
|
-
export declare function assertValidApiName(name: string): void;
|
|
7
|
-
/** Default `["api"]` when the caller omitted `--name`. Rejects duplicates and invalid slugs. */
|
|
8
|
-
export declare function parseApiNames(raw: readonly string[] | undefined): string[];
|
|
9
|
-
export declare function isDecohereWorkspace(dir: string): boolean;
|
|
10
|
-
/** Directory names under `projects/` that already have a `package.json`. */
|
|
11
|
-
export declare function listExistingApiNames(dir: string): string[];
|
|
12
|
-
/** `billing` → `BILLING`, `admin-api` → `ADMIN_API` — prefix for `{PREFIX}_DB_HOST`. */
|
|
13
|
-
export declare function apiEnvPrefix(apiName: string): string;
|
|
14
|
-
export declare function apiNameFromProjectDir(dir: string): string;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/** Default API project slug when `--name` is omitted. */
|
|
2
|
-
export declare const DEFAULT_WEBAPI_NAME = "api";
|
|
3
|
-
/** Relative path of an API project inside the monorepo. */
|
|
4
|
-
export declare function webapiProjectDir(name: string): string;
|
|
5
|
-
/**
|
|
6
|
-
* Forge release entry for a scaffolded API (`pack: true` → per-target outDir).
|
|
7
|
-
* Keep in sync with root `package.json` `"start"` / `"start:<name>"` and Dockerfiles.
|
|
8
|
-
*/
|
|
9
|
-
export declare function webapiReleaseEntry(name: string): string;
|
|
10
|
-
/** npm package name for a scaffolded API (`flux serve --project`). */
|
|
11
|
-
export declare function webapiPackageName(workspaceName: string, apiName: string): string;
|
|
12
|
-
/** Local listen port for the nth API (0-based). Production uses `PORT`. */
|
|
13
|
-
export declare function webapiPort(index: number): number;
|
|
14
|
-
/** @deprecated Use `webapiProjectDir(name)`. Default path for the first API. */
|
|
15
|
-
export declare const WEBAPI_PROJECT_DIR: string;
|
|
16
|
-
/** @deprecated Use `webapiReleaseEntry(name)`. Default start entry for the first API. */
|
|
17
|
-
export declare const WEBAPI_RELEASE_ENTRY: string;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export { WEBAPI_PROJECT_DIR, WEBAPI_RELEASE_ENTRY } from "./const.js";
|
|
2
|
-
export type ApiOptions = {
|
|
3
|
-
d?: string;
|
|
4
|
-
/** Host project name (directory basename). Required when scaffolding into `/workspace`. */
|
|
5
|
-
projectName?: string;
|
|
6
|
-
/** API slugs under `projects/`. Default `["api"]`. Repeatable `--name`. */
|
|
7
|
-
names?: string[];
|
|
8
|
-
/** Add APIs to an existing Decohere workspace instead of creating a new one. */
|
|
9
|
-
add?: boolean;
|
|
10
|
-
authProvider?: "auth0" | "none";
|
|
11
|
-
databaseProvider?: "none" | "postgres/typeorm";
|
|
12
|
-
postmanProvider?: "api" | "local" | "none";
|
|
13
|
-
installDependencies?: "yes" | "no";
|
|
14
|
-
};
|
|
15
|
-
export declare function scaffoldApi(cliOptions: ApiOptions): Promise<void>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Feature } from "../../services/scaffold.service.js";
|
|
2
|
-
export type AuthOptions = {
|
|
3
|
-
authProvider?: "auth0" | "none";
|
|
4
|
-
issuerBaseUrl?: string;
|
|
5
|
-
audience?: string;
|
|
6
|
-
databaseProvider?: "none" | "postgres/typeorm";
|
|
7
|
-
adminUsername?: string;
|
|
8
|
-
adminPassword?: string;
|
|
9
|
-
};
|
|
10
|
-
export declare const AuthFeature: Feature<AuthOptions>;
|