create-we8 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +97 -0
- package/dist/cli.js.map +1 -0
- package/dist/copy-template.d.ts +12 -0
- package/dist/copy-template.d.ts.map +1 -0
- package/dist/copy-template.js +36 -0
- package/dist/copy-template.js.map +1 -0
- package/dist/files.d.ts +55 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +373 -0
- package/dist/files.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/options.d.ts +78 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +235 -0
- package/dist/options.js.map +1 -0
- package/dist/prompts.d.ts +24 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +66 -0
- package/dist/prompts.js.map +1 -0
- package/dist/scaffold.d.ts +49 -0
- package/dist/scaffold.d.ts.map +1 -0
- package/dist/scaffold.js +178 -0
- package/dist/scaffold.js.map +1 -0
- package/package.json +58 -0
- package/template/.env.example +15 -0
- package/template/README.md +202 -0
- package/template/astro.config.mjs +23 -0
- package/template/package.json +29 -0
- package/template/public/favicon.svg +5 -0
- package/template/src/components/AnswerBlock.astro +31 -0
- package/template/src/components/JsonLd.astro +8 -0
- package/template/src/components/PostCard.astro +24 -0
- package/template/src/components/PostCta.astro +61 -0
- package/template/src/components/ResourceCard.astro +40 -0
- package/template/src/components/SiteFooter.astro +19 -0
- package/template/src/components/SiteHead.astro +36 -0
- package/template/src/components/SiteHeader.astro +34 -0
- package/template/src/layouts/BaseLayout.astro +61 -0
- package/template/src/layouts/PostLayout.astro +128 -0
- package/template/src/lib/data.ts +217 -0
- package/template/src/lib/fixture-backend.ts +84 -0
- package/template/src/lib/fixtures.ts +307 -0
- package/template/src/lib/markdown.ts +66 -0
- package/template/src/lib/seo.ts +191 -0
- package/template/src/lib/types.ts +180 -0
- package/template/src/lib/we8-backend.ts +254 -0
- package/template/src/pages/about.astro +96 -0
- package/template/src/pages/authors/[slug].astro +113 -0
- package/template/src/pages/blog/[slug].astro +28 -0
- package/template/src/pages/blog/index.astro +75 -0
- package/template/src/pages/contact.astro +106 -0
- package/template/src/pages/index.astro +106 -0
- package/template/src/pages/llms.txt.ts +64 -0
- package/template/src/pages/resources/[slug].astro +25 -0
- package/template/src/pages/resources.astro +95 -0
- package/template/src/pages/robots.txt.ts +18 -0
- package/template/src/pages/sitemap.xml.ts +22 -0
- package/template/src/styles/global.css +449 -0
- package/template/test/data-layer.test.ts +312 -0
- package/template/test/seo.test.ts +177 -0
- package/template/tsconfig.json +11 -0
- package/template/vitest.config.ts +18 -0
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# create-we8
|
|
2
|
+
|
|
3
|
+
The scaffolder behind `npm create we8`. One command produces a project that is
|
|
4
|
+
a we8 CMS on Cloudflare Workers, and optionally the Astro starter site
|
|
5
|
+
alongside it.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm create we8 my-site
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
It asks six questions, each with a default (where the project goes, its name,
|
|
12
|
+
whether to include the Astro starter, the D1 and R2 names, and the public
|
|
13
|
+
origin), and writes:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
my-site/
|
|
17
|
+
package.json depends on @we8/cms, @we8/cloudflare, @we8/admin-app
|
|
18
|
+
wrangler.jsonc generated by the pack: D1, R2, vars, cron, assets
|
|
19
|
+
src/index.ts the whole worker: compose the CMS, register the sender
|
|
20
|
+
tsconfig.json
|
|
21
|
+
.dev.vars.example BETTER_AUTH_SECRET, with no usable default
|
|
22
|
+
.gitignore
|
|
23
|
+
public/ where `npm run admin:bundle` puts the admin portal
|
|
24
|
+
README.md the exact commands from here to a deployed CMS
|
|
25
|
+
site/ the Astro starter, when you asked for it
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The generated project is the CMS worker plus configuration. `src/index.ts` is
|
|
29
|
+
three imports and a default export, because everything a site changes lives in
|
|
30
|
+
`wrangler.jsonc` or behind the admin API.
|
|
31
|
+
|
|
32
|
+
## Requirements
|
|
33
|
+
|
|
34
|
+
- Node 20 or newer and npm. Nothing global: `npm create we8` fetches this
|
|
35
|
+
scaffolder on demand.
|
|
36
|
+
- The generated project depends on `@we8/cms`, `@we8/cloudflare`, and
|
|
37
|
+
`@we8/admin-app`; with the Astro template it adds a `site/` workspace on
|
|
38
|
+
`@we8/astro` (Node 22.12 or newer for that path, Astro 7's floor).
|
|
39
|
+
- A Cloudflare account only at deploy time. Everything up to that point,
|
|
40
|
+
including the CMS, the portal, and the site, runs locally.
|
|
41
|
+
## Non-interactive
|
|
42
|
+
|
|
43
|
+
Every question is also a flag, so a script or a CI job never has to answer a
|
|
44
|
+
prompt:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
npm create we8 my-site -- --yes --headless --site-url https://example.com
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`--yes` takes the defaults and asks nothing, and `--headless` is shorthand for
|
|
51
|
+
`--template none`. The `--` matters: it is what makes npm pass the flags
|
|
52
|
+
through instead of reading them itself. See `npm create we8 -- --help` for the
|
|
53
|
+
whole list.
|
|
54
|
+
|
|
55
|
+
## Scripts in the new project
|
|
56
|
+
|
|
57
|
+
| Script | What it does |
|
|
58
|
+
| --- | --- |
|
|
59
|
+
| `npm run dev` | `wrangler dev` |
|
|
60
|
+
| `npm run deploy` | `wrangler deploy` |
|
|
61
|
+
| `npm run db:migrate` | The `@we8/cms` migrations, locally |
|
|
62
|
+
| `npm run db:migrate:remote` | The same, against the deployed database |
|
|
63
|
+
| `npm run db:seed` | Development data, local only, always |
|
|
64
|
+
| `npm run doctor` | What is missing, and the command that fixes it |
|
|
65
|
+
| `npm run doctor:remote` | The same, including the deployed Worker's secrets |
|
|
66
|
+
| `npm run admin:bundle` | Copies the built admin portal into `public/` |
|
|
67
|
+
| `npm run typecheck` | `tsc --noEmit` over the project |
|
|
68
|
+
| `npm run site:dev` | The Astro starter's dev server (with a template) |
|
|
69
|
+
| `npm run site:build` | The Astro starter's static build (with a template) |
|
|
70
|
+
|
|
71
|
+
## Working from a checkout
|
|
72
|
+
|
|
73
|
+
`--from-workspace` links `@we8/cms`, `@we8/cloudflare`, `@we8/astro`, and
|
|
74
|
+
`@we8/client` from a local we8-package checkout instead of the registry, with
|
|
75
|
+
`file:` dependencies npm resolves as links. It is how this repo tests the
|
|
76
|
+
scaffolder end to end before anything is published. Point it somewhere
|
|
77
|
+
explicitly with `--from-workspace <path>` or `WE8_WORKSPACE_ROOT`; with
|
|
78
|
+
neither, it walks up from the installed package.
|
|
79
|
+
|
|
80
|
+
See [docs/quick-start.md](https://github.com/reveriext/we8-package/blob/main/docs/quick-start.md) for the three paths a
|
|
81
|
+
new project can take, and [docs/deploy.md](https://github.com/reveriext/we8-package/blob/main/docs/deploy.md) for the pack,
|
|
82
|
+
the doctor, and the bindings inventory in full.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `npm create we8`. Parse, ask whatever is still unanswered, scaffold, then
|
|
4
|
+
* print the next three commands, because the moment a scaffolder finishes is
|
|
5
|
+
* the moment someone needs to know what to type.
|
|
6
|
+
*/
|
|
7
|
+
export declare function main(argv?: readonly string[], cwd?: string): Promise<number>;
|
|
8
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;GAIG;AA0BH,wBAAsB,IAAI,CACxB,IAAI,GAAE,SAAS,MAAM,EAA0B,EAC/C,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,MAAM,CAAC,CA6EjB"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `npm create we8`. Parse, ask whatever is still unanswered, scaffold, then
|
|
4
|
+
* print the next three commands, because the moment a scaffolder finishes is
|
|
5
|
+
* the moment someone needs to know what to type.
|
|
6
|
+
*/
|
|
7
|
+
import { relative } from 'node:path';
|
|
8
|
+
import { USAGE, parseArgs, resolveOptions } from './options.js';
|
|
9
|
+
import { promptForAnswers, terminalAsker } from './prompts.js';
|
|
10
|
+
import { scaffoldProject } from './scaffold.js';
|
|
11
|
+
const VERSION = '0.1.0';
|
|
12
|
+
function nextSteps(options, result, cwd) {
|
|
13
|
+
const where = relative(cwd, result.directory) || '.';
|
|
14
|
+
const steps = [];
|
|
15
|
+
steps.push(`cd ${where}`);
|
|
16
|
+
if (!result.installed)
|
|
17
|
+
steps.push('npm install');
|
|
18
|
+
steps.push('npx wrangler login');
|
|
19
|
+
if (!options.databaseId)
|
|
20
|
+
steps.push(`npx wrangler d1 create ${options.databaseName}`);
|
|
21
|
+
steps.push(`npx wrangler r2 bucket create ${options.bucketName}`);
|
|
22
|
+
steps.push('cp .dev.vars.example .dev.vars # then: openssl rand -hex 32');
|
|
23
|
+
steps.push('npm run db:migrate');
|
|
24
|
+
steps.push('npm run dev');
|
|
25
|
+
return steps;
|
|
26
|
+
}
|
|
27
|
+
export async function main(argv = process.argv.slice(2), cwd = process.cwd()) {
|
|
28
|
+
const parsed = parseArgs(argv);
|
|
29
|
+
if (parsed.error) {
|
|
30
|
+
console.error(parsed.error);
|
|
31
|
+
console.error('');
|
|
32
|
+
process.stdout.write(USAGE);
|
|
33
|
+
return 1;
|
|
34
|
+
}
|
|
35
|
+
if (parsed.mode === 'help') {
|
|
36
|
+
process.stdout.write(USAGE);
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
if (parsed.mode === 'version') {
|
|
40
|
+
console.log(VERSION);
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
let answers = parsed.answers;
|
|
44
|
+
// Questions need a terminal on both ends. A piped or scripted run gets the
|
|
45
|
+
// defaults instead of hanging on a prompt nobody can see.
|
|
46
|
+
const interactive = !parsed.yes && process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
47
|
+
if (interactive) {
|
|
48
|
+
const asker = terminalAsker();
|
|
49
|
+
try {
|
|
50
|
+
console.log('');
|
|
51
|
+
console.log('create-we8: a we8 CMS on Cloudflare Workers.');
|
|
52
|
+
console.log('Press enter to take the value in brackets.');
|
|
53
|
+
console.log('');
|
|
54
|
+
answers = await promptForAnswers(answers, asker, cwd);
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
asker.close();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const resolved = resolveOptions(answers, cwd);
|
|
61
|
+
if (!resolved.options) {
|
|
62
|
+
console.error(resolved.error ?? 'could not work out what to scaffold');
|
|
63
|
+
return 1;
|
|
64
|
+
}
|
|
65
|
+
const options = resolved.options;
|
|
66
|
+
let result;
|
|
67
|
+
try {
|
|
68
|
+
result = scaffoldProject(options, cwd);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
72
|
+
return 1;
|
|
73
|
+
}
|
|
74
|
+
console.log('');
|
|
75
|
+
console.log(`Created ${options.projectName} in ${result.directory}`);
|
|
76
|
+
console.log(result.templateCopied
|
|
77
|
+
? ' the CMS worker, plus the Astro starter in site/'
|
|
78
|
+
: ' the CMS worker, headless');
|
|
79
|
+
if (result.workspaceRoot) {
|
|
80
|
+
console.log(` we8 packages linked from ${result.workspaceRoot}`);
|
|
81
|
+
}
|
|
82
|
+
for (const warning of result.warnings) {
|
|
83
|
+
console.log(` note: ${warning}`);
|
|
84
|
+
}
|
|
85
|
+
console.log('');
|
|
86
|
+
console.log('Next:');
|
|
87
|
+
for (const step of nextSteps(options, result, cwd)) {
|
|
88
|
+
console.log(` ${step}`);
|
|
89
|
+
}
|
|
90
|
+
console.log('');
|
|
91
|
+
console.log('README.md in the new project has the whole path, including deploy.');
|
|
92
|
+
console.log('`npm run doctor` says what is still missing at any point.');
|
|
93
|
+
console.log('');
|
|
94
|
+
return 0;
|
|
95
|
+
}
|
|
96
|
+
process.exitCode = await main();
|
|
97
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAwB,MAAM,cAAc,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAuB,MAAM,eAAe,CAAC;AAErE,MAAM,OAAO,GAAG,OAAO,CAAC;AAExB,SAAS,SAAS,CAAC,OAAwB,EAAE,MAAsB,EAAE,GAAW;IAC9E,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC;IACrD,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,CAAC,IAAI,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC;IAC1B,IAAI,CAAC,MAAM,CAAC,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACjD,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACjC,IAAI,CAAC,OAAO,CAAC,UAAU;QAAE,KAAK,CAAC,IAAI,CAAC,0BAA0B,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IACtF,KAAK,CAAC,IAAI,CAAC,iCAAiC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;I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C,aAAa,EAAE,CAAC;QACzB,OAAO,CAAC,GAAG,CAAC,8BAA8B,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACtC,OAAO,CAAC,GAAG,CAAC,WAAW,OAAO,EAAE,CAAC,CAAC;IACpC,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrB,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;QACnD,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;IAClF,OAAO,CAAC,GAAG,CAAC,2DAA2D,CAAC,CAAC;IACzE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAEhB,OAAO,CAAC,CAAC;AACX,CAAC;AAED,OAAO,CAAC,QAAQ,GAAG,MAAM,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A pack-time step, not a runtime one: copies `templates/astro-starter` into
|
|
3
|
+
* this package as `template/`, so the published scaffolder carries the starter
|
|
4
|
+
* with it. The template workspace is private and never published, and a
|
|
5
|
+
* scaffolder that had to download its own template would be a scaffolder that
|
|
6
|
+
* does not work offline.
|
|
7
|
+
*
|
|
8
|
+
* Run by `prepack`. In the repo, `resolveTemplateDir` falls back to the
|
|
9
|
+
* workspace, so this only matters on the way to npm.
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=copy-template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-template.d.ts","sourceRoot":"","sources":["../src/copy-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A pack-time step, not a runtime one: copies `templates/astro-starter` into
|
|
3
|
+
* this package as `template/`, so the published scaffolder carries the starter
|
|
4
|
+
* with it. The template workspace is private and never published, and a
|
|
5
|
+
* scaffolder that had to download its own template would be a scaffolder that
|
|
6
|
+
* does not work offline.
|
|
7
|
+
*
|
|
8
|
+
* Run by `prepack`. In the repo, `resolveTemplateDir` falls back to the
|
|
9
|
+
* workspace, so this only matters on the way to npm.
|
|
10
|
+
*/
|
|
11
|
+
import { cpSync, existsSync, rmSync } from 'node:fs';
|
|
12
|
+
import { dirname, join, resolve } from 'node:path';
|
|
13
|
+
import { fileURLToPath } from 'node:url';
|
|
14
|
+
import { BUNDLED_TEMPLATE_DIR } from './scaffold.js';
|
|
15
|
+
const EXCLUDES = new Set(['node_modules', 'dist', '.astro']);
|
|
16
|
+
function main() {
|
|
17
|
+
const packageDir = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
18
|
+
const source = resolve(packageDir, '..', '..', 'templates', 'astro-starter');
|
|
19
|
+
const destination = join(packageDir, BUNDLED_TEMPLATE_DIR);
|
|
20
|
+
if (!existsSync(source)) {
|
|
21
|
+
console.error(`no template at ${source}; the published package would ship without one`);
|
|
22
|
+
return 1;
|
|
23
|
+
}
|
|
24
|
+
rmSync(destination, { recursive: true, force: true });
|
|
25
|
+
cpSync(source, destination, {
|
|
26
|
+
recursive: true,
|
|
27
|
+
filter: (from) => {
|
|
28
|
+
const name = from.slice(source.length + 1).split(/[/\\]/)[0];
|
|
29
|
+
return name === undefined || !EXCLUDES.has(name);
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
console.log(`bundled the Astro starter into ${destination}`);
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
process.exitCode = main();
|
|
36
|
+
//# sourceM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,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7D,OAAO,IAAI,KAAK,SAAS,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACnD,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,kCAAkC,WAAW,EAAE,CAAC,CAAC;IAC7D,OAAO,CAAC,CAAC;AACX,CAAC;AAED,OAAO,CAAC,QAAQ,GAAG,IAAI,EAAE,CAAC"}
|
package/dist/files.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every file the scaffolder writes, as pure functions of the answers. Keeping
|
|
3
|
+
* the contents here rather than inside the directory walk means the generated
|
|
4
|
+
* project can be asserted on in tests without a filesystem.
|
|
5
|
+
*
|
|
6
|
+
* The generated worker is deliberately tiny. The app IS the CMS worker: three
|
|
7
|
+
* imports, one registration, one default export. Everything a site changes is
|
|
8
|
+
* configuration, which is why `wrangler.jsonc` is the file with the comments
|
|
9
|
+
* in it and `src/index.ts` is the file with almost nothing.
|
|
10
|
+
*/
|
|
11
|
+
import { type ScaffoldOptions } from './options.js';
|
|
12
|
+
/** The CMS version a fresh project reports from `/v1/health`. */
|
|
13
|
+
export declare const CMS_VERSION = "0.1.0";
|
|
14
|
+
/** One generated file: where it goes and what is in it. */
|
|
15
|
+
export interface GeneratedFile {
|
|
16
|
+
path: string;
|
|
17
|
+
contents: string;
|
|
18
|
+
}
|
|
19
|
+
/** How the generated project names its we8 dependencies. */
|
|
20
|
+
export interface DependencySpecs {
|
|
21
|
+
cms: string;
|
|
22
|
+
cloudflare: string;
|
|
23
|
+
astro: string;
|
|
24
|
+
client: string;
|
|
25
|
+
admin: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Registry ranges normally; `file:` paths into a checkout under
|
|
29
|
+
* `--from-workspace`, which is how this repo proves the scaffolder works
|
|
30
|
+
* before anything is published. npm links a `file:` directory rather than
|
|
31
|
+
* copying it, so a rebuild in the checkout is picked up straight away.
|
|
32
|
+
*/
|
|
33
|
+
export declare function dependencySpecs(options: ScaffoldOptions, workspaceRoot: string | null): DependencySpecs;
|
|
34
|
+
/** The project manifest. */
|
|
35
|
+
export declare function projectPackageJson(options: ScaffoldOptions, deps: DependencySpecs): string;
|
|
36
|
+
/** The worker. */
|
|
37
|
+
export declare function workerEntry(options: ScaffoldOptions): string;
|
|
38
|
+
/** The local secrets template. */
|
|
39
|
+
export declare function devVarsExample(): string;
|
|
40
|
+
/** The project's gitignore. `.dev.vars` is the line that matters. */
|
|
41
|
+
export declare function gitignore(options: ScaffoldOptions): string;
|
|
42
|
+
/** The project's tsconfig: enough to typecheck the worker and nothing more. */
|
|
43
|
+
export declare function tsconfig(): string;
|
|
44
|
+
/** The project's wrangler config, from the pack's generator. */
|
|
45
|
+
export declare function wranglerConfig(options: ScaffoldOptions): string;
|
|
46
|
+
/**
|
|
47
|
+
* The README: the whole path from here to a deployed CMS, as commands that can
|
|
48
|
+
* be pasted in order. This is the file a stranger reads first and the only
|
|
49
|
+
* place the ordering constraints (database before migrate, secret before
|
|
50
|
+
* sign-up) are written down in one list.
|
|
51
|
+
*/
|
|
52
|
+
export declare function readme(options: ScaffoldOptions): string;
|
|
53
|
+
/** Everything except the copied template, which is a directory walk rather than a string. */
|
|
54
|
+
export declare function generatedFiles(options: ScaffoldOptions, deps: DependencySpecs): GeneratedFile[];
|
|
55
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAEvE,iEAAiE;AACjE,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,2DAA2D;AAC3D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAA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