@forumone/create-throughline 0.0.1 → 0.2.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE +21 -0
  3. package/README.md +41 -43
  4. package/dist/bin.d.ts +3 -0
  5. package/dist/bin.d.ts.map +1 -0
  6. package/dist/bin.js +45 -0
  7. package/dist/bin.js.map +1 -0
  8. package/dist/generator.d.ts +48 -0
  9. package/dist/generator.d.ts.map +1 -0
  10. package/dist/generator.js +131 -0
  11. package/dist/generator.js.map +1 -0
  12. package/dist/index.d.ts +5 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +5 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/post-install.d.ts +9 -0
  17. package/dist/post-install.d.ts.map +1 -0
  18. package/dist/post-install.js +68 -0
  19. package/dist/post-install.js.map +1 -0
  20. package/dist/prompts.d.ts +23 -0
  21. package/dist/prompts.d.ts.map +1 -0
  22. package/dist/prompts.js +89 -0
  23. package/dist/prompts.js.map +1 -0
  24. package/dist/templates/base/.env.example +43 -0
  25. package/dist/templates/base/README.md +96 -0
  26. package/dist/templates/base/apps/web/next-env.d.ts +5 -0
  27. package/dist/templates/base/apps/web/next.config.mjs +10 -0
  28. package/dist/templates/base/apps/web/package.json.template +42 -0
  29. package/dist/templates/base/apps/web/src/app/(frontend)/layout.tsx +22 -0
  30. package/dist/templates/base/apps/web/src/app/(frontend)/page.tsx +18 -0
  31. package/dist/templates/base/apps/web/src/app/(payload)/admin/[[...segments]]/not-found.tsx +12 -0
  32. package/dist/templates/base/apps/web/src/app/(payload)/admin/[[...segments]]/page.tsx +16 -0
  33. package/dist/templates/base/apps/web/src/app/(payload)/admin/importMap.js +6 -0
  34. package/dist/templates/base/apps/web/src/app/(payload)/api/[...slug]/route.ts +16 -0
  35. package/dist/templates/base/apps/web/src/app/(payload)/layout.tsx +23 -0
  36. package/dist/templates/base/apps/web/src/app/api/inngest/route.ts.template +56 -0
  37. package/dist/templates/base/apps/web/src/payload.config.ts.template +164 -0
  38. package/dist/templates/base/apps/web/tsconfig.json +24 -0
  39. package/dist/templates/base/package.json.template +23 -0
  40. package/dist/templates/base/pnpm-workspace.yaml +3 -0
  41. package/dist/templates/base/tsconfig.json +14 -0
  42. package/dist/templates/base/turbo.json +27 -0
  43. package/dist/templates/with-reference-ds/packages/design-system/package.json.template +18 -0
  44. package/dist/templates/with-reference-ds/packages/design-system/src/index.ts +6 -0
  45. package/dist/templates/with-reference-ds/packages/design-system/src/manifest.ts +6 -0
  46. package/dist/templates/with-reference-ds/packages/design-system/tsconfig.json +9 -0
  47. package/dist/templates/without-reference-ds/packages/design-system/README.md +19 -0
  48. package/dist/templates/without-reference-ds/packages/design-system/package.json.template +14 -0
  49. package/dist/templates/without-reference-ds/packages/design-system/src/index.ts +8 -0
  50. package/dist/utils/templates.d.ts +11 -0
  51. package/dist/utils/templates.d.ts.map +1 -0
  52. package/dist/utils/templates.js +31 -0
  53. package/dist/utils/templates.js.map +1 -0
  54. package/package.json +64 -7
package/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # @forumone/create-throughline
2
+
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 7ee992d: Fix broken external installs of the core plugins.
8
+
9
+ Every core plugin emits a runtime `import { getPluginRegistry } from '@forumone/throughline-plugin-contract'`, but `plugin-contract` was marked `private` and never published — so the published plugins pinned `@forumone/throughline-plugin-contract: 0.0.0`, a version that does not exist on npm, and any external `pnpm install` failed with a 404.
10
+
11
+ `plugin-contract` is now published, so the dependent plugins re-pin a real version. The cross-plugin registry is keyed on a global `Symbol.for(...)` and stored on the Payload instance, so behavior is unchanged.
12
+
13
+ Also fixes the scaffolder, which pinned `@forumone/throughline-reference-ds@^0.1.0` (latest is `0.2.0`) in the generated `apps/web` and `design-system` packages.
14
+
15
+ ## 0.2.0
16
+
17
+ ### Minor Changes
18
+
19
+ - 2dac330: Initial release of `@forumone/create-throughline`. Interactive CLI that scaffolds a new Throughline project: pnpm monorepo with Payload CMS + all eight Throughline plugins wired (audit, components, publishing, approvals, audit-query, integrations, email, forms), an Inngest endpoint registering every framework function, an `.env.example` listing every required secret, and an optional reference-design-system overlay. Run with `pnpm create @forumone/throughline my-project`.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Forum One Communications Corporation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,45 +1,43 @@
1
1
  # @forumone/create-throughline
2
2
 
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
4
-
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
6
-
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
8
-
9
- ## Purpose
10
-
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@forumone/create-throughline`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
15
-
16
- ## What is OIDC Trusted Publishing?
17
-
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
19
-
20
- ## Setup Instructions
21
-
22
- To properly configure OIDC trusted publishing for this package:
23
-
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
28
-
29
- ## DO NOT USE THIS PACKAGE
30
-
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
36
-
37
- ## More Information
38
-
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
42
-
43
- ---
44
-
45
- **Maintained for OIDC setup purposes only**
3
+ Scaffolder for new Throughline projects (Payload CMS + MCP servers + Inngest workflows).
4
+
5
+ ## Usage
6
+
7
+ ```bash
8
+ pnpm create @forumone/throughline my-client-site
9
+ ```
10
+
11
+ Or with npm:
12
+
13
+ ```bash
14
+ npm create @forumone/throughline@latest my-client-site
15
+ ```
16
+
17
+ The scaffolder asks a small set of questions, then generates a ready-to-run
18
+ pnpm monorepo with Payload, all Throughline plugins, and an Inngest endpoint
19
+ already wired. After scaffolding you'll need to fill in environment variables,
20
+ implement client-specific resolvers (users, groups, approvers), and replace
21
+ the example content model with your own.
22
+
23
+ ## What you get
24
+
25
+ ```
26
+ my-client-site/
27
+ ├── apps/
28
+ │ └── web/ # Next.js + Payload with all plugins wired
29
+ ├── packages/
30
+ │ ├── design-system/ # Reference DS (or placeholder for your own)
31
+ │ ├── content/ # Client-specific collections & blocks
32
+ │ └── brand/ # Brand tokens + email theme
33
+ ├── .env.example
34
+ ├── pnpm-workspace.yaml
35
+ ├── turbo.json
36
+ └── README.md
37
+ ```
38
+
39
+ ## After scaffolding
40
+
41
+ Read the generated `README.md` for full setup instructions. Expect 1–2 hours
42
+ from `pnpm create` to "Claude editing a real page" for the first project.
43
+ Subsequent projects should be much faster as you accumulate reusable patterns.
package/dist/bin.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=bin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
package/dist/bin.js ADDED
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+ import { intro, outro, cancel, spinner } from '@clack/prompts';
3
+ import pc from 'picocolors';
4
+ import { gatherAnswers } from './prompts.js';
5
+ import { generate } from './generator.js';
6
+ import { printNextSteps } from './post-install.js';
7
+ const VERSION = '0.1.0';
8
+ async function main() {
9
+ // eslint-disable-next-line no-console
10
+ console.log();
11
+ intro(`${pc.bgMagenta(pc.white(' Throughline '))} ${pc.dim(`v${VERSION}`)}`);
12
+ const targetDir = process.argv[2];
13
+ if (!targetDir) {
14
+ cancel('Please provide a project name: pnpm create @forumone/throughline my-project');
15
+ process.exit(1);
16
+ }
17
+ const answers = await gatherAnswers({ targetDir });
18
+ const s = spinner();
19
+ let active = false;
20
+ try {
21
+ await generate(answers, {
22
+ onProgress: (step) => {
23
+ if (active)
24
+ s.stop(step);
25
+ s.start(step);
26
+ active = true;
27
+ },
28
+ });
29
+ if (active)
30
+ s.stop('Done');
31
+ }
32
+ catch (error) {
33
+ if (active)
34
+ s.stop(pc.red('Failed'));
35
+ cancel(error instanceof Error ? error.message : String(error));
36
+ process.exit(1);
37
+ }
38
+ printNextSteps(answers);
39
+ outro(pc.green('Ready.'));
40
+ }
41
+ main().catch((error) => {
42
+ process.stderr.write(`${pc.red('Unexpected error:')} ${error instanceof Error ? error.stack ?? error.message : String(error)}\n`);
43
+ process.exit(1);
44
+ });
45
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,MAAM,YAAY,CAAA;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,MAAM,OAAO,GAAG,OAAO,CAAA;AAEvB,KAAK,UAAU,IAAI;IACjB,sCAAsC;IACtC,OAAO,CAAC,GAAG,EAAE,CAAA;IACb,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,IAAI,OAAO,EAAE,CAAC,EAAE,CAAC,CAAA;IAE5E,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,CAAC,6EAA6E,CAAC,CAAA;QACrF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,EAAE,SAAS,EAAE,CAAC,CAAA;IAElD,MAAM,CAAC,GAAG,OAAO,EAAE,CAAA;IACnB,IAAI,MAAM,GAAG,KAAK,CAAA;IAClB,IAAI,CAAC;QACH,MAAM,QAAQ,CAAC,OAAO,EAAE;YACtB,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE;gBACnB,IAAI,MAAM;oBAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBACxB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;gBACb,MAAM,GAAG,IAAI,CAAA;YACf,CAAC;SACF,CAAC,CAAA;QACF,IAAI,MAAM;YAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,MAAM;YAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;QACpC,MAAM,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;QAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IAED,cAAc,CAAC,OAAO,CAAC,CAAA;IACvB,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;AAC3B,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC9B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACjI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,48 @@
1
+ import { rename, rm, stat } from 'node:fs/promises';
2
+ import type { Answers } from './prompts.js';
3
+ export interface GenerateOptions {
4
+ /** Override the templates directory (used by tests). */
5
+ templatesDir?: string;
6
+ /** Skip side effects: `git init` + `pnpm install`. Used by tests. */
7
+ skipSideEffects?: boolean;
8
+ /** Optional progress callback for spinners. */
9
+ onProgress?: (step: string) => void;
10
+ }
11
+ /**
12
+ * Generates a new Throughline monorepo at `answers.targetDir`. Always:
13
+ * - copies `templates/base` into the target dir, with `{{var}}` templating
14
+ * applied to every text file (skipping common binary suffixes)
15
+ * - either renders the `with-reference-ds` overlay or the `without-reference-ds`
16
+ * overlay onto the result, based on `answers.useReferenceDs`
17
+ *
18
+ * Side-effect steps (`git init`, `pnpm install`) are gated behind
19
+ * `options.skipSideEffects` so tests can run the generator in a temp dir
20
+ * without spawning subprocesses.
21
+ */
22
+ export declare function generate(answers: Answers, options?: GenerateOptions): Promise<void>;
23
+ interface RenderArgs {
24
+ source: string;
25
+ target: string;
26
+ data: Record<string, unknown>;
27
+ }
28
+ /**
29
+ * Recursively copies `source` into `target`, applying `renderTemplate` to
30
+ * the contents of every text file and to filenames containing `{{var}}`
31
+ * markers. Files with `.template` suffix have the suffix stripped after
32
+ * rendering so we can author templates with realistic names without
33
+ * triggering tooling (e.g. `package.json.template`).
34
+ *
35
+ * Binary files (matched by extension) are copied byte-for-byte. Empty
36
+ * directories are preserved so the scaffold can ship placeholder dirs.
37
+ */
38
+ declare function renderDirectory({ source, target, data }: RenderArgs): Promise<void>;
39
+ declare function isBinary(filename: string): boolean;
40
+ export declare const __testing: {
41
+ renderDirectory: typeof renderDirectory;
42
+ isBinary: typeof isBinary;
43
+ rename: typeof rename;
44
+ rm: typeof rm;
45
+ stat: typeof stat;
46
+ };
47
+ export {};
48
+ //# sourceMappingURL=generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAa,MAAM,kBAAkB,CAAA;AAI5F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAK3C,MAAM,WAAW,eAAe;IAC9B,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,qEAAqE;IACrE,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CACpC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6B7F;AAED,UAAU,UAAU;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AAED;;;;;;;;;GASG;AACH,iBAAe,eAAe,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAmClF;AAiBD,iBAAS,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAI3C;AA6BD,eAAO,MAAM,SAAS;;;;;;CAAkD,CAAA"}
@@ -0,0 +1,131 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { cp, mkdir, readFile, readdir, rename, rm, stat, writeFile } from 'node:fs/promises';
3
+ import { dirname, join, resolve } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { renderTemplate } from './utils/templates.js';
6
+ const __dirname = dirname(fileURLToPath(import.meta.url));
7
+ const DEFAULT_TEMPLATES_DIR = resolve(__dirname, 'templates');
8
+ /**
9
+ * Generates a new Throughline monorepo at `answers.targetDir`. Always:
10
+ * - copies `templates/base` into the target dir, with `{{var}}` templating
11
+ * applied to every text file (skipping common binary suffixes)
12
+ * - either renders the `with-reference-ds` overlay or the `without-reference-ds`
13
+ * overlay onto the result, based on `answers.useReferenceDs`
14
+ *
15
+ * Side-effect steps (`git init`, `pnpm install`) are gated behind
16
+ * `options.skipSideEffects` so tests can run the generator in a temp dir
17
+ * without spawning subprocesses.
18
+ */
19
+ export async function generate(answers, options = {}) {
20
+ const templatesDir = options.templatesDir ?? DEFAULT_TEMPLATES_DIR;
21
+ const onProgress = options.onProgress ?? (() => { });
22
+ onProgress('Creating project structure');
23
+ await mkdir(answers.targetDir, { recursive: true });
24
+ await renderDirectory({
25
+ source: join(templatesDir, 'base'),
26
+ target: answers.targetDir,
27
+ data: answers,
28
+ });
29
+ onProgress(answers.useReferenceDs ? 'Wiring reference design system' : 'Preparing design system placeholder');
30
+ const overlay = answers.useReferenceDs ? 'with-reference-ds' : 'without-reference-ds';
31
+ await renderDirectory({
32
+ source: join(templatesDir, overlay),
33
+ target: answers.targetDir,
34
+ data: answers,
35
+ });
36
+ if (answers.initializeGit && !options.skipSideEffects) {
37
+ onProgress('Initializing git');
38
+ await initGit(answers.targetDir);
39
+ }
40
+ if (answers.installDeps && !options.skipSideEffects) {
41
+ onProgress('Installing dependencies (this may take a minute)');
42
+ await installDependencies(answers.targetDir);
43
+ }
44
+ }
45
+ /**
46
+ * Recursively copies `source` into `target`, applying `renderTemplate` to
47
+ * the contents of every text file and to filenames containing `{{var}}`
48
+ * markers. Files with `.template` suffix have the suffix stripped after
49
+ * rendering so we can author templates with realistic names without
50
+ * triggering tooling (e.g. `package.json.template`).
51
+ *
52
+ * Binary files (matched by extension) are copied byte-for-byte. Empty
53
+ * directories are preserved so the scaffold can ship placeholder dirs.
54
+ */
55
+ async function renderDirectory({ source, target, data }) {
56
+ let entries;
57
+ try {
58
+ entries = await readdir(source, { withFileTypes: true });
59
+ }
60
+ catch (error) {
61
+ if (error.code === 'ENOENT')
62
+ return;
63
+ throw error;
64
+ }
65
+ await mkdir(target, { recursive: true });
66
+ for (const entry of entries) {
67
+ const renderedName = renderTemplate(entry.name, data);
68
+ const sourcePath = join(source, entry.name);
69
+ const targetPath = join(target, renderedName);
70
+ if (entry.isDirectory()) {
71
+ await renderDirectory({ source: sourcePath, target: targetPath, data });
72
+ continue;
73
+ }
74
+ if (!entry.isFile())
75
+ continue;
76
+ if (isBinary(entry.name)) {
77
+ await cp(sourcePath, targetPath);
78
+ continue;
79
+ }
80
+ const raw = await readFile(sourcePath, 'utf-8');
81
+ const rendered = renderTemplate(raw, data);
82
+ const finalPath = targetPath.endsWith('.template')
83
+ ? targetPath.slice(0, -'.template'.length)
84
+ : targetPath;
85
+ await writeFile(finalPath, rendered);
86
+ }
87
+ }
88
+ const BINARY_EXTENSIONS = new Set([
89
+ '.png',
90
+ '.jpg',
91
+ '.jpeg',
92
+ '.gif',
93
+ '.webp',
94
+ '.ico',
95
+ '.woff',
96
+ '.woff2',
97
+ '.ttf',
98
+ '.otf',
99
+ '.pdf',
100
+ '.zip',
101
+ ]);
102
+ function isBinary(filename) {
103
+ const dot = filename.lastIndexOf('.');
104
+ if (dot === -1)
105
+ return false;
106
+ return BINARY_EXTENSIONS.has(filename.slice(dot).toLowerCase());
107
+ }
108
+ async function initGit(dir) {
109
+ await runCommand('git', ['init'], dir);
110
+ await runCommand('git', ['add', '.'], dir);
111
+ await runCommand('git', ['commit', '-m', 'Initial commit from create-throughline'], dir);
112
+ }
113
+ async function installDependencies(dir) {
114
+ await runCommand('pnpm', ['install'], dir);
115
+ }
116
+ function runCommand(cmd, args, cwd) {
117
+ return new Promise((resolvePromise, reject) => {
118
+ const child = spawn(cmd, args, { cwd, stdio: 'inherit' });
119
+ child.on('exit', (code) => {
120
+ if (code === 0)
121
+ resolvePromise();
122
+ else
123
+ reject(new Error(`${cmd} ${args.join(' ')} exited with code ${code}`));
124
+ });
125
+ child.on('error', reject);
126
+ });
127
+ }
128
+ // Re-exports kept around so tests in adjacent packages can stub these without
129
+ // reaching into the implementation. Not part of the public API surface.
130
+ export const __testing = { renderDirectory, isBinary, rename, rm, stat };
131
+ //# sourceMappingURL=generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,C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Answers, validateProjectName } from './prompts.js';
2
+ export { generate, type GenerateOptions } from './generator.js';
3
+ export { renderTemplate } from './utils/templates.js';
4
+ export { printNextSteps } from './post-install.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAC/E,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { gatherAnswers, validateProjectName } from './prompts.js';
2
+ export { generate } from './generator.js';
3
+ export { renderTemplate } from './utils/templates.js';
4
+ export { printNextSteps } from './post-install.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAgB,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAC/E,OAAO,EAAE,QAAQ,EAAwB,MAAM,gBAAgB,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1,9 @@
1
+ import type { Answers } from './prompts.js';
2
+ /**
3
+ * Prints a numbered punch list of post-install steps. Order is the order
4
+ * a developer should follow; conditional steps (e.g. "pnpm install") only
5
+ * appear when the corresponding answer was `false` so the list reads
6
+ * cleanly either way.
7
+ */
8
+ export declare function printNextSteps(answers: Answers): void;
9
+ //# sourceMappingURL=post-install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-install.d.ts","sourceRoot":"","sources":["../src/post-install.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAE3C;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkFrD"}
@@ -0,0 +1,68 @@
1
+ import { basename } from 'node:path';
2
+ import pc from 'picocolors';
3
+ /**
4
+ * Prints a numbered punch list of post-install steps. Order is the order
5
+ * a developer should follow; conditional steps (e.g. "pnpm install") only
6
+ * appear when the corresponding answer was `false` so the list reads
7
+ * cleanly either way.
8
+ */
9
+ export function printNextSteps(answers) {
10
+ const lines = [];
11
+ let step = 1;
12
+ const dirName = basename(answers.targetDir);
13
+ lines.push(formatStep(step++, `${pc.bold('cd')} ${dirName}`));
14
+ if (!answers.installDeps) {
15
+ lines.push(formatStep(step++, pc.bold('pnpm install')));
16
+ }
17
+ lines.push(formatStep(step++, `Copy ${pc.bold('.env.example')} to ${pc.bold('.env.local')} and fill in values`));
18
+ if (answers.databasePlatform === 'neon') {
19
+ lines.push(` ${pc.dim('- Create a Neon project; use its connection string for DATABASE_URI')}`);
20
+ }
21
+ else if (answers.databasePlatform === 'supabase') {
22
+ lines.push(` ${pc.dim('- Create a Supabase project; use the pooled connection string for DATABASE_URI')}`);
23
+ }
24
+ else {
25
+ lines.push(` ${pc.dim('- Provision a Postgres database and set DATABASE_URI to its connection string')}`);
26
+ }
27
+ lines.push(formatStep(step++, 'Generate required secrets:'));
28
+ lines.push(` ${pc.dim('openssl rand -base64 48 # PAYLOAD_SECRET')}`);
29
+ lines.push(` ${pc.dim('openssl rand -base64 48 # APPROVAL_TOKEN_SECRET')}`);
30
+ lines.push(` ${pc.dim('openssl rand -base64 48 # FORMS_IP_HASH_SECRET')}`);
31
+ lines.push(formatStep(step++, `${pc.bold('pnpm dev')} to run locally`));
32
+ lines.push(formatStep(step++, 'Open http://localhost:3000/admin and create your first admin user'));
33
+ lines.push(formatStep(step++, 'In the admin, go to API Keys and create one key per MCP server'));
34
+ lines.push(formatStep(step++, 'Paste those keys into .env.local'));
35
+ lines.push(formatStep(step++, 'Wire Claude (or your MCP client) to your MCP endpoints — see the generated README.md'));
36
+ // eslint-disable-next-line no-console
37
+ console.log();
38
+ // eslint-disable-next-line no-console
39
+ console.log(pc.bold('Next steps:'));
40
+ // eslint-disable-next-line no-console
41
+ console.log();
42
+ for (const line of lines) {
43
+ // eslint-disable-next-line no-console
44
+ console.log(line);
45
+ }
46
+ // eslint-disable-next-line no-console
47
+ console.log();
48
+ // eslint-disable-next-line no-console
49
+ console.log(pc.dim('Customizations you will likely need to make:'));
50
+ const customizations = [
51
+ 'Replace the example Pages collection with your content model',
52
+ 'Implement the groupResolver and user resolvers in payload.config.ts',
53
+ 'Add your destinations to the formsPlugin allowlist',
54
+ ];
55
+ if (!answers.useReferenceDs) {
56
+ customizations.push('Point componentsPlugin at your design system manifest URL');
57
+ }
58
+ for (const item of customizations) {
59
+ // eslint-disable-next-line no-console
60
+ console.log(` ${pc.dim(`- ${item}`)}`);
61
+ }
62
+ // eslint-disable-next-line no-console
63
+ console.log();
64
+ }
65
+ function formatStep(n, body) {
66
+ return `${pc.cyan(` ${n}.`)} ${body}`;
67
+ }
68
+ //# sourceMappingURL=post-install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-install.js","sourceRoot":"","sources":["../src/post-install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,MAAM,YAAY,CAAA;AAG3B;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,IAAI,IAAI,GAAG,CAAC,CAAA;IAEZ,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IAC3C,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,CA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E,CAAC,CAAA;IACzC,CAAC;IAED,sCAAsC;IACtC,OAAO,CAAC,GAAG,EAAE,CAAA;AACf,CAAC;AAED,SAAS,UAAU,CAAC,CAAS,EAAE,IAAY;IACzC,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAA;AACxC,CAAC"}
@@ -0,0 +1,23 @@
1
+ export type DeploymentPlatform = 'vercel' | 'railway' | 'fly' | 'other';
2
+ export type DatabasePlatform = 'neon' | 'supabase' | 'self-hosted-postgres';
3
+ export interface Answers {
4
+ /** Absolute path to the directory the scaffolder will create. */
5
+ targetDir: string;
6
+ /** Slug-style name written into root package.json. */
7
+ projectName: string;
8
+ /** npm scope (without leading `@`); empty string means "no scope". */
9
+ packageScope: string;
10
+ useReferenceDs: boolean;
11
+ initializeGit: boolean;
12
+ installDeps: boolean;
13
+ deploymentPlatform: DeploymentPlatform;
14
+ databasePlatform: DatabasePlatform;
15
+ }
16
+ /** Validates a project name slug. Returns an error message or `undefined` if OK. */
17
+ export declare function validateProjectName(value: string): string | undefined;
18
+ /** Validates an npm scope (without `@`). Empty string is allowed and means "no scope". */
19
+ export declare function validatePackageScope(value: string): string | undefined;
20
+ export declare function gatherAnswers({ targetDir }: {
21
+ targetDir: string;
22
+ }): Promise<Answers>;
23
+ //# sourceMappingURL=prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,SAAS,GAAG,KAAK,GAAG,OAAO,CAAA;AACvE,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,UAAU,GAAG,sBAAsB,CAAA;AAE3E,MAAM,WAAW,OAAO;IACtB,iEAAiE;IACjE,SAAS,EAAE,MAAM,CAAA;IACjB,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAA;IACnB,sEAAsE;IACtE,YAAY,EAAE,MAAM,CAAA;IACpB,cAAc,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,OAAO,CAAA;IACtB,WAAW,EAAE,OAAO,CAAA;IACpB,kBAAkB,EAAE,kBAAkB,CAAA;IACtC,gBAAgB,EAAE,gBAAgB,CAAA;CACnC;AAED,oFAAoF;AACpF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOrE;AAED,0FAA0F;AAC1F,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOtE;AAED,wBAAsB,aAAa,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CA6E1F"}
@@ -0,0 +1,89 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { resolve, basename } from 'node:path';
3
+ import { cancel, confirm, group, isCancel, select, text } from '@clack/prompts';
4
+ /** Validates a project name slug. Returns an error message or `undefined` if OK. */
5
+ export function validateProjectName(value) {
6
+ if (!value)
7
+ return 'Project name is required';
8
+ if (!/^[a-z0-9][a-z0-9-]*$/.test(value)) {
9
+ return 'Use lowercase letters, numbers, and hyphens only (must start with a letter or number)';
10
+ }
11
+ if (value.length > 64)
12
+ return 'Project name must be 64 characters or fewer';
13
+ return undefined;
14
+ }
15
+ /** Validates an npm scope (without `@`). Empty string is allowed and means "no scope". */
16
+ export function validatePackageScope(value) {
17
+ if (value === '')
18
+ return undefined;
19
+ if (!/^[a-z0-9][a-z0-9-]*$/.test(value)) {
20
+ return 'Use lowercase letters, numbers, and hyphens only, or leave blank';
21
+ }
22
+ if (value.length > 39)
23
+ return 'Scope must be 39 characters or fewer';
24
+ return undefined;
25
+ }
26
+ export async function gatherAnswers({ targetDir }) {
27
+ const absoluteTarget = resolve(process.cwd(), targetDir);
28
+ if (existsSync(absoluteTarget)) {
29
+ cancel(`Directory "${targetDir}" already exists. Choose a different name or remove it.`);
30
+ process.exit(1);
31
+ }
32
+ const defaultProjectName = basename(absoluteTarget) || 'throughline-project';
33
+ const answers = await group({
34
+ projectName: () => text({
35
+ message: 'Project name (used in package.json):',
36
+ initialValue: defaultProjectName,
37
+ validate: (value) => validateProjectName(value),
38
+ }),
39
+ packageScope: () => text({
40
+ message: 'npm scope for internal workspace packages (without @, blank to skip):',
41
+ placeholder: 'acme',
42
+ initialValue: '',
43
+ validate: (value) => validatePackageScope(value),
44
+ }),
45
+ useReferenceDs: () => confirm({
46
+ message: 'Use the Throughline reference design system as a starting point?',
47
+ initialValue: true,
48
+ }),
49
+ deploymentPlatform: () => select({
50
+ message: 'Where will this deploy?',
51
+ options: [
52
+ { value: 'vercel', label: 'Vercel', hint: 'Recommended for Phase 1' },
53
+ { value: 'railway', label: 'Railway', hint: 'Long-running container' },
54
+ { value: 'fly', label: 'Fly.io', hint: 'Long-running container' },
55
+ { value: 'other', label: 'Other / decide later' },
56
+ ],
57
+ }),
58
+ databasePlatform: () => select({
59
+ message: 'Postgres provider?',
60
+ options: [
61
+ { value: 'neon', label: 'Neon', hint: 'Recommended; branch-per-preview' },
62
+ { value: 'supabase', label: 'Supabase' },
63
+ { value: 'self-hosted-postgres', label: 'Self-hosted Postgres' },
64
+ ],
65
+ }),
66
+ initializeGit: () => confirm({
67
+ message: 'Initialize a git repository?',
68
+ initialValue: true,
69
+ }),
70
+ installDeps: () => confirm({
71
+ message: 'Install dependencies now? (you can do this later with `pnpm install`)',
72
+ initialValue: true,
73
+ }),
74
+ }, {
75
+ onCancel: () => {
76
+ cancel('Cancelled.');
77
+ process.exit(0);
78
+ },
79
+ });
80
+ if (isCancel(answers)) {
81
+ cancel('Cancelled.');
82
+ process.exit(0);
83
+ }
84
+ return {
85
+ targetDir: absoluteTarget,
86
+ ...answers,
87
+ };
88
+ }
89
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.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