@byline/cli 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +373 -0
- package/README.md +23 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +72 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +36 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/init.d.ts +16 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +76 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/context.d.ts +38 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +37 -0
- package/dist/context.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/pg-url.d.ts +11 -0
- package/dist/lib/pg-url.d.ts.map +1 -0
- package/dist/lib/pg-url.js +22 -0
- package/dist/lib/pg-url.js.map +1 -0
- package/dist/manifest/deps.d.ts +29 -0
- package/dist/manifest/deps.d.ts.map +1 -0
- package/dist/manifest/deps.js +97 -0
- package/dist/manifest/deps.js.map +1 -0
- package/dist/manifest/env.d.ts +18 -0
- package/dist/manifest/env.d.ts.map +1 -0
- package/dist/manifest/env.js +38 -0
- package/dist/manifest/env.js.map +1 -0
- package/dist/phases/db-init.d.ts +3 -0
- package/dist/phases/db-init.d.ts.map +1 -0
- package/dist/phases/db-init.js +163 -0
- package/dist/phases/db-init.js.map +1 -0
- package/dist/phases/db.d.ts +11 -0
- package/dist/phases/db.d.ts.map +1 -0
- package/dist/phases/db.js +93 -0
- package/dist/phases/db.js.map +1 -0
- package/dist/phases/deps.d.ts +3 -0
- package/dist/phases/deps.d.ts.map +1 -0
- package/dist/phases/deps.js +115 -0
- package/dist/phases/deps.js.map +1 -0
- package/dist/phases/env.d.ts +3 -0
- package/dist/phases/env.d.ts.map +1 -0
- package/dist/phases/env.js +172 -0
- package/dist/phases/env.js.map +1 -0
- package/dist/phases/host.d.ts +3 -0
- package/dist/phases/host.d.ts.map +1 -0
- package/dist/phases/host.js +99 -0
- package/dist/phases/host.js.map +1 -0
- package/dist/phases/index.d.ts +7 -0
- package/dist/phases/index.d.ts.map +1 -0
- package/dist/phases/index.js +40 -0
- package/dist/phases/index.js.map +1 -0
- package/dist/phases/preflight.d.ts +4 -0
- package/dist/phases/preflight.d.ts.map +1 -0
- package/dist/phases/preflight.js +81 -0
- package/dist/phases/preflight.js.map +1 -0
- package/dist/phases/routes.d.ts +3 -0
- package/dist/phases/routes.d.ts.map +1 -0
- package/dist/phases/routes.js +145 -0
- package/dist/phases/routes.js.map +1 -0
- package/dist/phases/scaffold.d.ts +3 -0
- package/dist/phases/scaffold.d.ts.map +1 -0
- package/dist/phases/scaffold.js +113 -0
- package/dist/phases/scaffold.js.map +1 -0
- package/dist/phases/stub.d.ts +3 -0
- package/dist/phases/stub.d.ts.map +1 -0
- package/dist/phases/stub.js +25 -0
- package/dist/phases/stub.js.map +1 -0
- package/dist/phases/ui.d.ts +3 -0
- package/dist/phases/ui.d.ts.map +1 -0
- package/dist/phases/ui.js +93 -0
- package/dist/phases/ui.js.map +1 -0
- package/dist/phases/wire/index.d.ts +3 -0
- package/dist/phases/wire/index.d.ts.map +1 -0
- package/dist/phases/wire/index.js +67 -0
- package/dist/phases/wire/index.js.map +1 -0
- package/dist/phases/wire/root-tsx.d.ts +3 -0
- package/dist/phases/wire/root-tsx.d.ts.map +1 -0
- package/dist/phases/wire/root-tsx.js +57 -0
- package/dist/phases/wire/root-tsx.js.map +1 -0
- package/dist/phases/wire/server-ts.d.ts +3 -0
- package/dist/phases/wire/server-ts.d.ts.map +1 -0
- package/dist/phases/wire/server-ts.js +54 -0
- package/dist/phases/wire/server-ts.js.map +1 -0
- package/dist/phases/wire/shared.d.ts +34 -0
- package/dist/phases/wire/shared.d.ts.map +1 -0
- package/dist/phases/wire/shared.js +2 -0
- package/dist/phases/wire/shared.js.map +1 -0
- package/dist/phases/wire/start-ts.d.ts +3 -0
- package/dist/phases/wire/start-ts.d.ts.map +1 -0
- package/dist/phases/wire/start-ts.js +149 -0
- package/dist/phases/wire/start-ts.js.map +1 -0
- package/dist/phases/wire/tsconfig.d.ts +3 -0
- package/dist/phases/wire/tsconfig.d.ts.map +1 -0
- package/dist/phases/wire/tsconfig.js +105 -0
- package/dist/phases/wire/tsconfig.js.map +1 -0
- package/dist/phases/wire/vite-config.d.ts +3 -0
- package/dist/phases/wire/vite-config.d.ts.map +1 -0
- package/dist/phases/wire/vite-config.js +46 -0
- package/dist/phases/wire/vite-config.js.map +1 -0
- package/dist/prompts.d.ts +34 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +49 -0
- package/dist/prompts.js.map +1 -0
- package/dist/runner.d.ts +5 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +91 -0
- package/dist/runner.js.map +1 -0
- package/dist/state.d.ts +18 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +68 -0
- package/dist/state.js.map +1 -0
- package/dist/templates/byline/admin.config.ts +41 -0
- package/dist/templates/byline/i18n.ts +47 -0
- package/dist/templates/byline/routes.ts +28 -0
- package/dist/templates/byline/seed.ts +19 -0
- package/dist/templates/byline/seeds/admin.ts +62 -0
- package/dist/templates/byline/server.config.ts +92 -0
- package/dist/templates/byline-examples/admin.config.ts +74 -0
- package/dist/templates/byline-examples/blocks/photo-block.ts +59 -0
- package/dist/templates/byline-examples/blocks/richtext-block.ts +35 -0
- package/dist/templates/byline-examples/collections/doc-example-flat-locale-all.ts +373 -0
- package/dist/templates/byline-examples/collections/doc-example-flat-locale-en.ts +283 -0
- package/dist/templates/byline-examples/collections/doc-example-tree-locale-all.ts +278 -0
- package/dist/templates/byline-examples/collections/doc-example-tree-locale-en.ts +205 -0
- package/dist/templates/byline-examples/collections/docs/admin.tsx +204 -0
- package/dist/templates/byline-examples/collections/docs/components/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/docs/components/feature-formatter.tsx +10 -0
- package/dist/templates/byline-examples/collections/docs/hooks/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/docs/index.ts +10 -0
- package/dist/templates/byline-examples/collections/docs/schema.ts +209 -0
- package/dist/templates/byline-examples/collections/docs-categories/admin.tsx +78 -0
- package/dist/templates/byline-examples/collections/docs-categories/components/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/docs-categories/hooks/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/docs-categories/index.ts +10 -0
- package/dist/templates/byline-examples/collections/docs-categories/schema.ts +33 -0
- package/dist/templates/byline-examples/collections/media/admin.tsx +188 -0
- package/dist/templates/byline-examples/collections/media/components/media-list-view.tsx +330 -0
- package/dist/templates/byline-examples/collections/media/components/media-thumbnail.tsx +63 -0
- package/dist/templates/byline-examples/collections/media/hooks/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/media/index.ts +10 -0
- package/dist/templates/byline-examples/collections/media/schema.ts +157 -0
- package/dist/templates/byline-examples/collections/news/admin.tsx +192 -0
- package/dist/templates/byline-examples/collections/news/components/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/news/hooks/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/news/index.ts +10 -0
- package/dist/templates/byline-examples/collections/news/schema.ts +91 -0
- package/dist/templates/byline-examples/collections/news-categories/admin.tsx +78 -0
- package/dist/templates/byline-examples/collections/news-categories/components/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/news-categories/hooks/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/news-categories/index.ts +10 -0
- package/dist/templates/byline-examples/collections/news-categories/schema.ts +33 -0
- package/dist/templates/byline-examples/collections/pages/admin.tsx +183 -0
- package/dist/templates/byline-examples/collections/pages/components/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/pages/hooks/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/pages/index.ts +10 -0
- package/dist/templates/byline-examples/collections/pages/schema.ts +96 -0
- package/dist/templates/byline-examples/components/length-indicator.tsx +138 -0
- package/dist/templates/byline-examples/components/pill.tsx +38 -0
- package/dist/templates/byline-examples/components/summary-length.tsx +39 -0
- package/dist/templates/byline-examples/fields/available-languages-field.ts +90 -0
- package/dist/templates/byline-examples/fields/lexical-richtext-compact.ts +88 -0
- package/dist/templates/byline-examples/i18n.ts +47 -0
- package/dist/templates/byline-examples/routes.ts +28 -0
- package/dist/templates/byline-examples/scripts/regenerate-media.ts +275 -0
- package/dist/templates/byline-examples/seed.ts +25 -0
- package/dist/templates/byline-examples/seeds/admin.ts +62 -0
- package/dist/templates/byline-examples/seeds/doc-categories.ts +71 -0
- package/dist/templates/byline-examples/seeds/docs.ts +293 -0
- package/dist/templates/byline-examples/seeds/news-categories.ts +71 -0
- package/dist/templates/byline-examples/server.config.ts +179 -0
- package/dist/templates/host/vite.config.ts +41 -0
- package/dist/templates/migrations/0000_condemned_kronos.sql +324 -0
- package/dist/templates/migrations/0001_sudden_phantom_reporter.sql +1 -0
- package/dist/templates/migrations/meta/0000_snapshot.json +2793 -0
- package/dist/templates/migrations/meta/0001_snapshot.json +2799 -0
- package/dist/templates/migrations/meta/_journal.json +20 -0
- package/dist/templates/routes/(byline)/admin/account/index.tsx +11 -0
- package/dist/templates/routes/(byline)/admin/collections/$collection/$id/api.tsx +16 -0
- package/dist/templates/routes/(byline)/admin/collections/$collection/$id/history.tsx +19 -0
- package/dist/templates/routes/(byline)/admin/collections/$collection/$id/index.tsx +16 -0
- package/dist/templates/routes/(byline)/admin/collections/$collection/create.tsx +11 -0
- package/dist/templates/routes/(byline)/admin/collections/$collection/index.tsx +11 -0
- package/dist/templates/routes/(byline)/admin/index.tsx +11 -0
- package/dist/templates/routes/(byline)/admin/permissions/index.tsx +11 -0
- package/dist/templates/routes/(byline)/admin/roles/$id/index.tsx +11 -0
- package/dist/templates/routes/(byline)/admin/roles/index.tsx +11 -0
- package/dist/templates/routes/(byline)/admin/route.tsx +11 -0
- package/dist/templates/routes/(byline)/admin/users/$id/index.tsx +11 -0
- package/dist/templates/routes/(byline)/admin/users/index.tsx +11 -0
- package/dist/templates/routes/(byline)/sign-in.tsx +11 -0
- package/dist/templates/ui-byline/blocks/photo-block/index.tsx +80 -0
- package/dist/templates/ui-byline/blocks/richtext-block/index.tsx +46 -0
- package/dist/templates/ui-byline/components/admonition/index.tsx +40 -0
- package/dist/templates/ui-byline/components/code/code-serializer.tsx +20 -0
- package/dist/templates/ui-byline/components/code/code.tsx +50 -0
- package/dist/templates/ui-byline/components/code/index.module.scss +137 -0
- package/dist/templates/ui-byline/components/code/index.ts +2 -0
- package/dist/templates/ui-byline/components/code/types.ts +5 -0
- package/dist/templates/ui-byline/components/code/utils.ts +20 -0
- package/dist/templates/ui-byline/components/heading-anchor/heading-anchor.tsx +69 -0
- package/dist/templates/ui-byline/components/heading-anchor/index.ts +1 -0
- package/dist/templates/ui-byline/components/heading-anchor/utils.ts +15 -0
- package/dist/templates/ui-byline/components/inline-image/index.tsx +109 -0
- package/dist/templates/ui-byline/components/layout/index.tsx +63 -0
- package/dist/templates/ui-byline/components/link/lang-link.tsx +70 -0
- package/dist/templates/ui-byline/components/link/link-field.tsx +298 -0
- package/dist/templates/ui-byline/components/link/link-lexical.tsx +191 -0
- package/dist/templates/ui-byline/components/list/index.ts +2 -0
- package/dist/templates/ui-byline/components/list/list-item.tsx +32 -0
- package/dist/templates/ui-byline/components/list/list.tsx +17 -0
- package/dist/templates/ui-byline/components/responsive-image/index.tsx +205 -0
- package/dist/templates/ui-byline/components/richtext-lexical/index.tsx +31 -0
- package/dist/templates/ui-byline/components/richtext-lexical/serialize/index.tsx +249 -0
- package/dist/templates/ui-byline/components/richtext-lexical/serialize/richtext-node-formats.ts +66 -0
- package/dist/templates/ui-byline/components/richtext-lexical/serialize/types.ts +48 -0
- package/dist/templates/ui-byline/components/richtext-lexical/serialize/utils.ts +15 -0
- package/dist/templates/ui-byline/components/table-cell/index.tsx +36 -0
- package/dist/templates/ui-byline/components/vimeo/index.tsx +21 -0
- package/dist/templates/ui-byline/components/youtube/index.tsx +22 -0
- package/dist/templates/ui-byline/render-blocks.tsx +71 -0
- package/dist/templates/ui-byline/types/i18n.ts +14 -0
- package/dist/templates/ui-byline/utils/image-sources.ts +102 -0
- package/dist/templates/ui-byline/utils/to-kebab-case.ts +5 -0
- package/dist/types.d.ts +54 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/diff.d.ts +4 -0
- package/dist/ui/diff.d.ts.map +1 -0
- package/dist/ui/diff.js +23 -0
- package/dist/ui/diff.js.map +1 -0
- package/dist/ui/grid.d.ts +7 -0
- package/dist/ui/grid.d.ts.map +1 -0
- package/dist/ui/grid.js +24 -0
- package/dist/ui/grid.js.map +1 -0
- package/dist/ui/logger.d.ts +14 -0
- package/dist/ui/logger.d.ts.map +1 -0
- package/dist/ui/logger.js +30 -0
- package/dist/ui/logger.js.map +1 -0
- package/dist/ui/snippet.d.ts +2 -0
- package/dist/ui/snippet.d.ts.map +1 -0
- package/dist/ui/snippet.js +7 -0
- package/dist/ui/snippet.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { Project } from 'ts-morph';
|
|
3
|
+
const REL = 'src/server.ts';
|
|
4
|
+
const IMPORT_SPECIFIER = '../byline/server.config';
|
|
5
|
+
const SNIPPET = `// Initialize Byline server config (DB adapter, etc.) before handling any requests.
|
|
6
|
+
import '${IMPORT_SPECIFIER}'
|
|
7
|
+
`;
|
|
8
|
+
export const wireServerTs = {
|
|
9
|
+
key: 'server-ts',
|
|
10
|
+
title: `Inject side-effect import into ${REL}`,
|
|
11
|
+
async preview(ctx) {
|
|
12
|
+
return run(ctx, true);
|
|
13
|
+
},
|
|
14
|
+
async apply(ctx) {
|
|
15
|
+
return run(ctx, false);
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
async function run(ctx, dryRun) {
|
|
19
|
+
const path = ctx.resolve(REL);
|
|
20
|
+
if (!existsSync(path)) {
|
|
21
|
+
return { status: 'blocked', message: `${REL} not found — host phase should have caught this` };
|
|
22
|
+
}
|
|
23
|
+
const text = readFileSync(path, 'utf8');
|
|
24
|
+
if (hasImport(text, IMPORT_SPECIFIER)) {
|
|
25
|
+
return { status: 'skipped', message: `${REL}: side-effect import already present` };
|
|
26
|
+
}
|
|
27
|
+
if (dryRun) {
|
|
28
|
+
return { status: 'done', message: `${REL}: will inject \`import '${IMPORT_SPECIFIER}'\`` };
|
|
29
|
+
}
|
|
30
|
+
const project = new Project({ useInMemoryFileSystem: false, skipAddingFilesFromTsConfig: true });
|
|
31
|
+
let source;
|
|
32
|
+
try {
|
|
33
|
+
source = project.addSourceFileAtPath(path);
|
|
34
|
+
}
|
|
35
|
+
catch (_e) {
|
|
36
|
+
return {
|
|
37
|
+
status: 'manual',
|
|
38
|
+
message: `${REL}: could not parse — please add the import manually`,
|
|
39
|
+
snippet: SNIPPET,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
// Place the side-effect import at the very top of the imports block so the
|
|
43
|
+
// Byline runtime is registered before any other module side effects fire.
|
|
44
|
+
source.insertImportDeclaration(0, { moduleSpecifier: IMPORT_SPECIFIER });
|
|
45
|
+
source.saveSync();
|
|
46
|
+
return { status: 'done', message: `${REL}: injected \`import '${IMPORT_SPECIFIER}'\`` };
|
|
47
|
+
}
|
|
48
|
+
function hasImport(source, specifier) {
|
|
49
|
+
// Match either form: with or without `.ts` extension, single or double quote.
|
|
50
|
+
const escaped = specifier.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
51
|
+
const re = new RegExp(`import\\s+['"]${escaped}(?:\\.ts)?['"]`);
|
|
52
|
+
return re.test(source);
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=server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OAAO,EAAE,GAAG,GAAG,2BAA2B,gBAAgB,KAAK,EAAE,CAAA;IAC5F,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,qBAAqB,EAAE,KAAK,EAAE,2BAA2B,EAAE,IAAI,EAAE,CAAC,CAAA;IAChG,IAAI,MAAkB,CAAA;IACtB,IAAI,CAAC;QACH,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAA;IAC5C,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;QACZ,OAAO;YACL,MAAM,EAAE,QAAQ;YAChB,OAAO,EAAE,GAAG,GAAG,oDAAoD;YACnE,OAAO,EAAE,OAAO;SACjB,CAAA;IACH,CAAC;IAED,2EAA2E;IAC3E,0EAA0E;IAC1E,MAAM,CAAC,uBAAuB,CAAC,CAAC,EAAE,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC,CAAA;IACxE,MAAM,CAAC,QAAQ,EAAE,CAAA;IAEjB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,wBAAwB,gBAAgB,KAAK,EAAE,CAAA;AACzF,CAAC;AAED,SAAS,SAAS,CAAC,MAAc,EAAE,SAAiB;IAClD,8EAA8E;IAC9E,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAA;IAChE,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,iBAAiB,OAAO,gBAAgB,CAAC,CAAA;IAC/D,OAAO,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AACxB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Context } from '../../context.js';
|
|
2
|
+
/**
|
|
3
|
+
* Outcome of a single wire sub-edit.
|
|
4
|
+
*
|
|
5
|
+
* done — the file changed (or the change is being applied right now in apply()).
|
|
6
|
+
* skipped — the file already had the wiring; no edit needed.
|
|
7
|
+
* manual — the change is too risky to automate (custom code, AST shape we don't
|
|
8
|
+
* recognise, file diverges from a known canonical) — the user must apply
|
|
9
|
+
* the printed `snippet` themselves.
|
|
10
|
+
* blocked — a hard error (file missing, unparseable, etc.) — installer cannot
|
|
11
|
+
* continue this sub-edit at all.
|
|
12
|
+
*
|
|
13
|
+
* Persisted into `state.wireSubEdits[<key>]` (only `'done' | 'manual' | 'skipped' |
|
|
14
|
+
* 'pending'` — `blocked` collapses to `'pending'` so re-run picks it up).
|
|
15
|
+
*/
|
|
16
|
+
export type SubEditStatus = 'done' | 'skipped' | 'manual' | 'blocked';
|
|
17
|
+
export interface SubEditResult {
|
|
18
|
+
status: SubEditStatus;
|
|
19
|
+
/** Human-readable, single line — used in plan() notes and apply() logs. */
|
|
20
|
+
message: string;
|
|
21
|
+
/** Set on `manual` to print the exact text the user should paste. */
|
|
22
|
+
snippet?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface SubEdit {
|
|
25
|
+
/** Stable key persisted into state.wireSubEdits. */
|
|
26
|
+
key: string;
|
|
27
|
+
/** Title shown in plan/preview. */
|
|
28
|
+
title: string;
|
|
29
|
+
/** Idempotent dry-check — no side effects. */
|
|
30
|
+
preview(ctx: Context): Promise<SubEditResult>;
|
|
31
|
+
/** Make the edit. May write files. */
|
|
32
|
+
apply(ctx: Context): Promise<SubEditResult>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/phases/wire/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE/C;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAA;AAErE,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,aAAa,CAAA;IACrB,2EAA2E;IAC3E,OAAO,EAAE,MAAM,CAAA;IACf,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,OAAO;IACtB,oDAAoD;IACpD,GAAG,EAAE,MAAM,CAAA;IACX,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAA;IACb,8CAA8C;IAC9C,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;IAC7C,sCAAsC;IACtC,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;CAC5C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/phases/wire/shared.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-ts.d.ts","sourceRoot":"","sources":["../../../src/phases/wire/start-ts.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAiB,MAAM,aAAa,CAAA;AAczD,eAAO,MAAM,WAAW,EAAE,OASzB,CAAA"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { Node, Project, SyntaxKind, } from 'ts-morph';
|
|
3
|
+
const REL = 'src/start.ts';
|
|
4
|
+
const ADAPTER_NAME = 'bylineCodedErrorAdapter';
|
|
5
|
+
const ADAPTER_MODULE = '@byline/host-tanstack-start/integrations/start-errors';
|
|
6
|
+
const SNIPPET = `import { createStart } from '@tanstack/react-start'
|
|
7
|
+
|
|
8
|
+
import { ${ADAPTER_NAME} } from '${ADAPTER_MODULE}'
|
|
9
|
+
|
|
10
|
+
export const startInstance = createStart(() => ({
|
|
11
|
+
serializationAdapters: [${ADAPTER_NAME}],
|
|
12
|
+
}))
|
|
13
|
+
`;
|
|
14
|
+
export const wireStartTs = {
|
|
15
|
+
key: 'start-ts',
|
|
16
|
+
title: `Register ${ADAPTER_NAME} in ${REL}`,
|
|
17
|
+
async preview(ctx) {
|
|
18
|
+
return run(ctx, true);
|
|
19
|
+
},
|
|
20
|
+
async apply(ctx) {
|
|
21
|
+
return run(ctx, false);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
async function run(ctx, dryRun) {
|
|
25
|
+
const path = ctx.resolve(REL);
|
|
26
|
+
if (!existsSync(path)) {
|
|
27
|
+
return { status: 'blocked', message: `${REL} not found — host phase should have caught this` };
|
|
28
|
+
}
|
|
29
|
+
const text = readFileSync(path, 'utf8');
|
|
30
|
+
// Cheap pre-check: if the adapter identifier is already referenced anywhere,
|
|
31
|
+
// assume the wiring is in place. Avoids a full AST round-trip on the common
|
|
32
|
+
// case where wire has already been run.
|
|
33
|
+
if (text.includes(ADAPTER_NAME)) {
|
|
34
|
+
return { status: 'skipped', message: `${REL}: ${ADAPTER_NAME} already registered` };
|
|
35
|
+
}
|
|
36
|
+
const project = new Project({ useInMemoryFileSystem: false, skipAddingFilesFromTsConfig: true });
|
|
37
|
+
let source;
|
|
38
|
+
try {
|
|
39
|
+
source = project.addSourceFileAtPath(path);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return manualBail(`${REL}: could not parse`);
|
|
43
|
+
}
|
|
44
|
+
const createStartCall = findCreateStartCall(source);
|
|
45
|
+
if (!createStartCall) {
|
|
46
|
+
return manualBail(`${REL}: no \`createStart(...)\` call found`);
|
|
47
|
+
}
|
|
48
|
+
const optionsLiteral = findReturnedOptionsObject(createStartCall);
|
|
49
|
+
if (!optionsLiteral) {
|
|
50
|
+
return manualBail(`${REL}: \`createStart\` factory does not return an inline object literal — cannot safely auto-edit`);
|
|
51
|
+
}
|
|
52
|
+
if (dryRun) {
|
|
53
|
+
return {
|
|
54
|
+
status: 'done',
|
|
55
|
+
message: `${REL}: will add ${ADAPTER_NAME} to serializationAdapters`,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
ensureImport(source);
|
|
59
|
+
ensureAdapterInOptions(optionsLiteral);
|
|
60
|
+
source.saveSync();
|
|
61
|
+
return { status: 'done', message: `${REL}: registered ${ADAPTER_NAME}` };
|
|
62
|
+
}
|
|
63
|
+
function manualBail(message) {
|
|
64
|
+
return { status: 'manual', message, snippet: SNIPPET };
|
|
65
|
+
}
|
|
66
|
+
function findCreateStartCall(source) {
|
|
67
|
+
// Walk top-level descendants looking for any `createStart(...)` call.
|
|
68
|
+
for (const call of source.getDescendantsOfKind(SyntaxKind.CallExpression)) {
|
|
69
|
+
const expr = call.getExpression();
|
|
70
|
+
if (expr.getText() === 'createStart')
|
|
71
|
+
return call;
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
function findReturnedOptionsObject(call) {
|
|
76
|
+
const args = call.getArguments();
|
|
77
|
+
if (args.length === 0)
|
|
78
|
+
return undefined;
|
|
79
|
+
const factory = args[0];
|
|
80
|
+
if (!factory)
|
|
81
|
+
return undefined;
|
|
82
|
+
// Two supported shapes:
|
|
83
|
+
// createStart(() => ({ ... })) <- ArrowFunction with parenthesised object body
|
|
84
|
+
// createStart(() => { return { ... } }) <- ArrowFunction with return statement
|
|
85
|
+
if (Node.isArrowFunction(factory) || Node.isFunctionExpression(factory)) {
|
|
86
|
+
const body = factory.getBody();
|
|
87
|
+
if (Node.isParenthesizedExpression(body)) {
|
|
88
|
+
const inner = body.getExpression();
|
|
89
|
+
if (Node.isObjectLiteralExpression(inner))
|
|
90
|
+
return inner;
|
|
91
|
+
}
|
|
92
|
+
if (Node.isObjectLiteralExpression(body))
|
|
93
|
+
return body;
|
|
94
|
+
if (Node.isBlock(body)) {
|
|
95
|
+
const ret = body.getStatements().find(Node.isReturnStatement);
|
|
96
|
+
if (ret) {
|
|
97
|
+
const expr = ret.getExpression();
|
|
98
|
+
if (expr && Node.isObjectLiteralExpression(expr))
|
|
99
|
+
return expr;
|
|
100
|
+
if (expr && Node.isParenthesizedExpression(expr)) {
|
|
101
|
+
const inner = expr.getExpression();
|
|
102
|
+
if (Node.isObjectLiteralExpression(inner))
|
|
103
|
+
return inner;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
function ensureImport(source) {
|
|
111
|
+
const existing = source
|
|
112
|
+
.getImportDeclarations()
|
|
113
|
+
.find((d) => d.getModuleSpecifierValue() === ADAPTER_MODULE);
|
|
114
|
+
if (existing) {
|
|
115
|
+
const already = existing.getNamedImports().some((n) => n.getName() === ADAPTER_NAME);
|
|
116
|
+
if (!already)
|
|
117
|
+
existing.addNamedImport(ADAPTER_NAME);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
// Insert after the last existing import; if none, at the top.
|
|
121
|
+
const imports = source.getImportDeclarations();
|
|
122
|
+
source.insertImportDeclaration(imports.length, {
|
|
123
|
+
moduleSpecifier: ADAPTER_MODULE,
|
|
124
|
+
namedImports: [ADAPTER_NAME],
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function ensureAdapterInOptions(options) {
|
|
128
|
+
const prop = options.getProperty('serializationAdapters');
|
|
129
|
+
if (!prop) {
|
|
130
|
+
options.addPropertyAssignment({
|
|
131
|
+
name: 'serializationAdapters',
|
|
132
|
+
initializer: `[${ADAPTER_NAME}]`,
|
|
133
|
+
});
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (!Node.isPropertyAssignment(prop))
|
|
137
|
+
return;
|
|
138
|
+
const init = prop.getInitializer();
|
|
139
|
+
if (!init || !Node.isArrayLiteralExpression(init))
|
|
140
|
+
return;
|
|
141
|
+
ensureAdapterInArray(init);
|
|
142
|
+
}
|
|
143
|
+
function ensureAdapterInArray(arr) {
|
|
144
|
+
const already = arr.getElements().some((el) => el.getText() === ADAPTER_NAME);
|
|
145
|
+
if (already)
|
|
146
|
+
return;
|
|
147
|
+
arr.addElement(ADAPTER_NAME);
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=start-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;QACV,OAAO,CAAC,qBAAqB,CAAC;YAC5B,IAAI,EAAE,uBAAuB;YAC7B,WAAW,EAAE,IAAI,YAAY,GAAG;SACjC,CAAC,CAAA;QACF,OAAM;IACR,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC;QAAE,OAAM;IAC5C,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;IAClC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC;QAAE,OAAM;IACzD,oBAAoB,CAAC,IAAI,CAAC,CAAA;AAC5B,CAAC;AAED,SAAS,oBAAoB,CAAC,GAA2B;IACvD,MAAM,OAAO,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,YAAY,CAAC,CAAA;IAC7E,IAAI,OAAO;QAAE,OAAM;IACnB,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;AAC9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsconfig.d.ts","sourceRoot":"","sources":["../../../src/phases/wire/tsconfig.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAiB,MAAM,aAAa,CAAA;AAczD,eAAO,MAAM,YAAY,EAAE,OAS1B,CAAA"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { applyEdits, modify, parse, parseTree } from 'jsonc-parser';
|
|
3
|
+
const REL = 'tsconfig.json';
|
|
4
|
+
const PATH_KEY = '~/*';
|
|
5
|
+
const PATH_VALUE = ['./byline/*'];
|
|
6
|
+
const SNIPPET = `// In tsconfig.json, ensure compilerOptions.paths contains the "~/*" alias:
|
|
7
|
+
{
|
|
8
|
+
"compilerOptions": {
|
|
9
|
+
"paths": {
|
|
10
|
+
"~/*": ["./byline/*"]
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}`;
|
|
14
|
+
export const wireTsconfig = {
|
|
15
|
+
key: 'tsconfig',
|
|
16
|
+
title: `Add compilerOptions.paths["${PATH_KEY}"] to ${REL}`,
|
|
17
|
+
async preview(ctx) {
|
|
18
|
+
return run(ctx, true);
|
|
19
|
+
},
|
|
20
|
+
async apply(ctx) {
|
|
21
|
+
return run(ctx, false);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
async function run(ctx, dryRun) {
|
|
25
|
+
const path = ctx.resolve(REL);
|
|
26
|
+
if (!existsSync(path)) {
|
|
27
|
+
return { status: 'blocked', message: `${REL} not found at the project root` };
|
|
28
|
+
}
|
|
29
|
+
const raw = readFileSync(path, 'utf8');
|
|
30
|
+
const errors = [];
|
|
31
|
+
const parsed = parse(raw, errors, { allowTrailingComma: true });
|
|
32
|
+
if (errors.length > 0 || !parsed) {
|
|
33
|
+
return {
|
|
34
|
+
status: 'manual',
|
|
35
|
+
message: `${REL}: could not parse as JSON / JSONC — please add the path mapping manually`,
|
|
36
|
+
snippet: SNIPPET,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const existing = parsed.compilerOptions?.paths?.[PATH_KEY];
|
|
40
|
+
if (Array.isArray(existing) && arraysEqual(existing, PATH_VALUE)) {
|
|
41
|
+
return { status: 'skipped', message: `${REL}: ${PATH_KEY} alias already correctly set` };
|
|
42
|
+
}
|
|
43
|
+
// The user has a *different* mapping for `~/*` — refuse to overwrite,
|
|
44
|
+
// bail to manual so they can decide how to reconcile.
|
|
45
|
+
if (existing !== undefined) {
|
|
46
|
+
return {
|
|
47
|
+
status: 'manual',
|
|
48
|
+
message: `${REL}: ${PATH_KEY} is mapped to a different value — refusing to overwrite`,
|
|
49
|
+
snippet: SNIPPET,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if (dryRun) {
|
|
53
|
+
return { status: 'done', message: `${REL}: will set ${PATH_KEY} → ${PATH_VALUE[0]}` };
|
|
54
|
+
}
|
|
55
|
+
const tree = parseTree(raw, [], { allowTrailingComma: true });
|
|
56
|
+
if (!tree) {
|
|
57
|
+
return {
|
|
58
|
+
status: 'manual',
|
|
59
|
+
message: `${REL}: could not build a syntax tree — please apply manually`,
|
|
60
|
+
snippet: SNIPPET,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// Inspect what already exists so we can choose the right anchor for `modify`.
|
|
64
|
+
const compilerOptions = findChild(tree, 'compilerOptions');
|
|
65
|
+
const paths = compilerOptions ? findChild(compilerOptions, 'paths') : undefined;
|
|
66
|
+
const indentChar = detectIndent(raw);
|
|
67
|
+
const edits = paths
|
|
68
|
+
? modify(raw, ['compilerOptions', 'paths', PATH_KEY], PATH_VALUE, {
|
|
69
|
+
formattingOptions: { tabSize: indentChar.size, insertSpaces: indentChar.spaces },
|
|
70
|
+
})
|
|
71
|
+
: compilerOptions
|
|
72
|
+
? modify(raw, ['compilerOptions', 'paths'], { [PATH_KEY]: PATH_VALUE }, {
|
|
73
|
+
formattingOptions: { tabSize: indentChar.size, insertSpaces: indentChar.spaces },
|
|
74
|
+
})
|
|
75
|
+
: modify(raw, ['compilerOptions'], { paths: { [PATH_KEY]: PATH_VALUE } }, { formattingOptions: { tabSize: indentChar.size, insertSpaces: indentChar.spaces } });
|
|
76
|
+
const next = applyEdits(raw, edits);
|
|
77
|
+
writeFileSync(path, next, 'utf8');
|
|
78
|
+
return { status: 'done', message: `${REL}: added ${PATH_KEY} → ${PATH_VALUE[0]}` };
|
|
79
|
+
}
|
|
80
|
+
function findChild(node, key) {
|
|
81
|
+
if (node.type !== 'object' || !node.children)
|
|
82
|
+
return undefined;
|
|
83
|
+
for (const prop of node.children) {
|
|
84
|
+
if (prop.type !== 'property' || !prop.children)
|
|
85
|
+
continue;
|
|
86
|
+
const [k, v] = prop.children;
|
|
87
|
+
if (k?.value === key)
|
|
88
|
+
return v;
|
|
89
|
+
}
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
function detectIndent(text) {
|
|
93
|
+
// Look at the first indented line.
|
|
94
|
+
const m = text.match(/\n([ \t]+)\S/);
|
|
95
|
+
if (!m)
|
|
96
|
+
return { size: 2, spaces: true };
|
|
97
|
+
const indent = m[1];
|
|
98
|
+
if (indent.startsWith('\t'))
|
|
99
|
+
return { size: 1, spaces: false };
|
|
100
|
+
return { size: indent.length, spaces: true };
|
|
101
|
+
}
|
|
102
|
+
function arraysEqual(a, b) {
|
|
103
|
+
return a.length === b.length && a.every((v, i) => v === b[i]);
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=tsconfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsconfig.js","sourceRoot":"","sources":["../../../src/phases/wire/tsconfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAa,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAK9E,MAAM,GAAG,GAAG,eAAe,CAAA;AAC3B,MAAM,QAAQ,GAAG,KAAK,CAAA;AACtB,MAAM,UAAU,GAAG,CAAC,YAAY,CAAC,CAAA;AACjC,MAAM,OAAO,GAAG;;;;;;;EAOd,CAAA;AAEF,MAAM,CAAC,MAAM,YAAY,GAAY;IACnC,GAAG,EAAE,UAAU;IACf,KAAK,EAAE,8BAA8B,QAAQ,SAAS,GAAG,EAAE;IAC3D,KAAK,CAAC,OAAO,CAAC,GAAG;QACf,OAAO,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACvB,CAAC;IACD,KAAK,CAAC,KAAK,CAAC,GAAG;QACb,OAAO,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IACxB,CAAC;CACF,CAAA;AAED,KAAK,UAAU,GAAG,CAAC,GAAY,EAAE,MAAe;IAC9C,MA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AA;IAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;AAC9C,CAAC;AAED,SAAS,WAAW,CAAC,CAAoB,EAAE,CAAoB;IAC7D,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC/D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-config.d.ts","sourceRoot":"","sources":["../../../src/phases/wire/vite-config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAiB,MAAM,aAAa,CAAA;AAKzD,eAAO,MAAM,cAAc,EAAE,OAS5B,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
const REL = 'vite.config.ts';
|
|
4
|
+
const TEMPLATE_REL = 'host/vite.config.ts';
|
|
5
|
+
export const wireViteConfig = {
|
|
6
|
+
key: 'vite-config',
|
|
7
|
+
title: `Verify ${REL} matches the canonical Byline-on-TanStack-Start config`,
|
|
8
|
+
async preview(ctx) {
|
|
9
|
+
return run(ctx, true);
|
|
10
|
+
},
|
|
11
|
+
async apply(ctx) {
|
|
12
|
+
return run(ctx, false);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
async function run(ctx, _dryRun) {
|
|
16
|
+
const path = ctx.resolve(REL);
|
|
17
|
+
if (!existsSync(path)) {
|
|
18
|
+
return {
|
|
19
|
+
status: 'blocked',
|
|
20
|
+
message: `${REL} not found — host phase should have caught this`,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const canonicalPath = join(ctx.templatesDir(), TEMPLATE_REL);
|
|
24
|
+
if (!existsSync(canonicalPath)) {
|
|
25
|
+
return {
|
|
26
|
+
status: 'blocked',
|
|
27
|
+
message: 'canonical vite.config.ts template missing from cli dist — was the package built?',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const userText = readFileSync(path, 'utf8');
|
|
31
|
+
const canonical = readFileSync(canonicalPath, 'utf8');
|
|
32
|
+
if (normalize(userText) === normalize(canonical)) {
|
|
33
|
+
return { status: 'skipped', message: `${REL}: already matches the canonical Byline config` };
|
|
34
|
+
}
|
|
35
|
+
// Per design decision #2: do not attempt to merge. Print canonical, bail to manual.
|
|
36
|
+
return {
|
|
37
|
+
status: 'manual',
|
|
38
|
+
message: `${REL}: differs from canonical — see snippet for required content`,
|
|
39
|
+
snippet: canonical,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function normalize(text) {
|
|
43
|
+
// Trailing whitespace + final newline differences shouldn't trigger manual.
|
|
44
|
+
return text.replace(/\s+$/g, '').replace(/\r\n/g, '\n');
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=vite-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-config.js","sourceRoot":"","sources":["../../../src/phases/wire/vite-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAKhC,MAAM,GAAG,GAAG,gBAAgB,CAAA;AAC5B,MAAM,YAAY,GAAG,qBAAqB,CAAA;AAE1C,MAAM,CAAC,MAAM,cAAc,GAAY;IACrC,GAAG,EAAE,aAAa;IAClB,KAAK,EAAE,UAAU,GAAG,wDAAwD;IAC5E,KAAK,CAAC,OAAO,CAAC,GAAG;QACf,OAAO,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACvB,CAAC;IACD,KAAK,CAAC,KAAK,CAAC,GAAG;QACb,OAAO,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,C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|
+
placeholder?: string;
|
|
5
|
+
defaultValue?: string;
|
|
6
|
+
}): Promise<string>;
|
|
7
|
+
password(opts: {
|
|
8
|
+
message: string;
|
|
9
|
+
}): Promise<string>;
|
|
10
|
+
select<T extends string>(opts: {
|
|
11
|
+
message: string;
|
|
12
|
+
options: {
|
|
13
|
+
value: T;
|
|
14
|
+
label: string;
|
|
15
|
+
hint?: string;
|
|
16
|
+
}[];
|
|
17
|
+
}): Promise<T>;
|
|
18
|
+
confirm(opts: {
|
|
19
|
+
message: string;
|
|
20
|
+
defaultValue?: boolean;
|
|
21
|
+
}): Promise<boolean>;
|
|
22
|
+
spinner(): {
|
|
23
|
+
start(msg: string): void;
|
|
24
|
+
stop(msg?: string): void;
|
|
25
|
+
};
|
|
26
|
+
intro(msg: string): void;
|
|
27
|
+
outro(msg: string): void;
|
|
28
|
+
note(body: string, title?: string): void;
|
|
29
|
+
cancel(msg: string): never;
|
|
30
|
+
}
|
|
31
|
+
export declare function createPrompter(opts?: {
|
|
32
|
+
yes?: boolean;
|
|
33
|
+
}): Prompter;
|
|
34
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,QAAQ;IACvB,IAAI,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAC7F,QAAQ,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IACpD,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE;QAC7B,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE;YAAE,KAAK,EAAE,CAAC,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KACtD,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACd,OAAO,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAC5E,OAAO,IAAI;QAAE,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAA;IACjE,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAA;CAC3B;AAED,wBAAgB,cAAc,CAAC,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,QAAQ,CAoCrE"}
|
package/dist/prompts.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as p from '@clack/prompts';
|
|
2
|
+
export function createPrompter(opts = {}) {
|
|
3
|
+
const yes = opts.yes === true;
|
|
4
|
+
return {
|
|
5
|
+
async text({ message, placeholder, defaultValue }) {
|
|
6
|
+
if (yes && defaultValue !== undefined)
|
|
7
|
+
return defaultValue;
|
|
8
|
+
const v = await p.text({ message, placeholder, defaultValue });
|
|
9
|
+
if (p.isCancel(v))
|
|
10
|
+
cancel('cancelled');
|
|
11
|
+
return v;
|
|
12
|
+
},
|
|
13
|
+
async password({ message }) {
|
|
14
|
+
const v = await p.password({ message });
|
|
15
|
+
if (p.isCancel(v))
|
|
16
|
+
cancel('cancelled');
|
|
17
|
+
return v;
|
|
18
|
+
},
|
|
19
|
+
async select({ message, options }) {
|
|
20
|
+
const first = options[0];
|
|
21
|
+
if (yes && first !== undefined)
|
|
22
|
+
return first.value;
|
|
23
|
+
const v = await p.select({ message, options: options });
|
|
24
|
+
if (p.isCancel(v))
|
|
25
|
+
cancel('cancelled');
|
|
26
|
+
return v;
|
|
27
|
+
},
|
|
28
|
+
async confirm({ message, defaultValue = true }) {
|
|
29
|
+
if (yes)
|
|
30
|
+
return defaultValue;
|
|
31
|
+
const v = await p.confirm({ message, initialValue: defaultValue });
|
|
32
|
+
if (p.isCancel(v))
|
|
33
|
+
cancel('cancelled');
|
|
34
|
+
return v;
|
|
35
|
+
},
|
|
36
|
+
spinner() {
|
|
37
|
+
return p.spinner();
|
|
38
|
+
},
|
|
39
|
+
intro: (m) => p.intro(m),
|
|
40
|
+
outro: (m) => p.outro(m),
|
|
41
|
+
note: (body, title) => p.note(body, title),
|
|
42
|
+
cancel,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function cancel(msg) {
|
|
46
|
+
p.cancel(msg);
|
|
47
|
+
process.exit(0);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAA;AAiBnC,MAAM,UAAU,cAAc,CAAC,OAA0B,EAAE;IACzD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,KAAK,IAAI,CAAA;IAE7B,OAAO;QACL,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE;YAC/C,IAAI,GAAG,IAAI,YAAY,KAAK,SAAS;gBAAE,OAAO,YAAY,CAAA;YAC1D,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,WAA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CAAA;QACpB,CAAC;QACD,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QACxB,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QACxB,IAAI,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC;QAC1C,MAAM;KACP,CAAA;AACH,CAAC;AAED,SAAS,MAAM,CAAC,GAAW;IACzB,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IACb,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC"}
|
package/dist/runner.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Context } from './context.js';
|
|
2
|
+
import type { Phase, Plan } from './types.js';
|
|
3
|
+
export declare function runPhase(phase: Phase, ctx: Context): Promise<void>;
|
|
4
|
+
export declare function executePlan(plan: Plan, ctx: Context): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAE7C,wBAAsB,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CA8CxE;AAkCD,wBAAsB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAQzE"}
|