create-indiepub 0.1.0 → 0.2.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/dist/index.js +9 -119
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
#!/usr/bin/env node
|
|
3
2
|
|
|
4
3
|
// src/index.ts
|
|
5
4
|
import * as p from "@clack/prompts";
|
|
@@ -27,83 +26,6 @@ var codeberg = (input) => {
|
|
|
27
26
|
subdir: subdir ? `${repo}/${subdir}` : repo
|
|
28
27
|
};
|
|
29
28
|
};
|
|
30
|
-
function genPackageJson(cfg) {
|
|
31
|
-
const name = slugify(cfg.dir.replace(/^\.\//, "")) || "my-indiepub-site";
|
|
32
|
-
const baseDeps = {
|
|
33
|
-
"@astrojs/cloudflare": "^12.0.0",
|
|
34
|
-
"@iconify-json/lucide": "^1.2.0",
|
|
35
|
-
"@indiepub/admin": "^0.1.0",
|
|
36
|
-
"@indiepub/astro": "^0.1.0",
|
|
37
|
-
"astro": "^5.0.0",
|
|
38
|
-
"astro-icon": "^1.1.5",
|
|
39
|
-
"drizzle-orm": "^0.38.0",
|
|
40
|
-
"nanoid": "^5.0.0"
|
|
41
|
-
};
|
|
42
|
-
const baseDevDeps = {
|
|
43
|
-
"@astrojs/check": "^0.9.0",
|
|
44
|
-
"@cloudflare/workers-types": "^4.0.0",
|
|
45
|
-
"@indiepub/types": "^0.1.0",
|
|
46
|
-
"typescript": "^5.0.0",
|
|
47
|
-
"wrangler": "^4.0.0"
|
|
48
|
-
};
|
|
49
|
-
let deps;
|
|
50
|
-
let devDeps;
|
|
51
|
-
if (cfg.template === "minimal") {
|
|
52
|
-
deps = {
|
|
53
|
-
"@astrojs/cloudflare": "^12.0.0",
|
|
54
|
-
"@indiepub/admin": "^0.1.0",
|
|
55
|
-
"@indiepub/astro": "^0.1.0",
|
|
56
|
-
"astro": "^5.0.0"
|
|
57
|
-
};
|
|
58
|
-
devDeps = {
|
|
59
|
-
"@cloudflare/workers-types": "^4.0.0",
|
|
60
|
-
"typescript": "^5.0.0",
|
|
61
|
-
"wrangler": "^4.0.0"
|
|
62
|
-
};
|
|
63
|
-
} else if (cfg.template === "byline") {
|
|
64
|
-
deps = {
|
|
65
|
-
...baseDeps,
|
|
66
|
-
"@indiepub/db": "^0.1.0",
|
|
67
|
-
"@tiptap/core": "^3.20.0",
|
|
68
|
-
"@tiptap/extension-image": "^3.20.0",
|
|
69
|
-
"@tiptap/extension-link": "^3.20.0",
|
|
70
|
-
"@tiptap/extension-placeholder": "^3.20.0",
|
|
71
|
-
"@tiptap/starter-kit": "^3.20.0",
|
|
72
|
-
"tiptap-markdown": "^0.9.0"
|
|
73
|
-
};
|
|
74
|
-
devDeps = { ...baseDevDeps };
|
|
75
|
-
} else if (cfg.template === "timeline") {
|
|
76
|
-
deps = {
|
|
77
|
-
...baseDeps,
|
|
78
|
-
"@iconify-json/simple-icons": "^1.0.0"
|
|
79
|
-
};
|
|
80
|
-
devDeps = { ...baseDevDeps };
|
|
81
|
-
} else {
|
|
82
|
-
deps = { ...baseDeps };
|
|
83
|
-
if (cfg.subscriptions) {
|
|
84
|
-
deps["@indiepub/email"] = "^0.1.0";
|
|
85
|
-
}
|
|
86
|
-
devDeps = { ...baseDevDeps };
|
|
87
|
-
}
|
|
88
|
-
return JSON.stringify(
|
|
89
|
-
{
|
|
90
|
-
name,
|
|
91
|
-
version: "0.0.1",
|
|
92
|
-
type: "module",
|
|
93
|
-
scripts: {
|
|
94
|
-
dev: "astro dev",
|
|
95
|
-
build: "astro build",
|
|
96
|
-
preview: "astro preview",
|
|
97
|
-
"db:migrate": "wrangler d1 migrations apply DB --local",
|
|
98
|
-
typecheck: "astro check"
|
|
99
|
-
},
|
|
100
|
-
dependencies: deps,
|
|
101
|
-
devDependencies: devDeps
|
|
102
|
-
},
|
|
103
|
-
null,
|
|
104
|
-
2
|
|
105
|
-
) + "\n";
|
|
106
|
-
}
|
|
107
29
|
function genAstroConfig(cfg) {
|
|
108
30
|
const siteUrl = cfg.authorUrl || "https://example.com";
|
|
109
31
|
const syndicationLines = [];
|
|
@@ -155,31 +77,6 @@ ${syndicationBlock}${subscriptionsBlock} }),
|
|
|
155
77
|
});
|
|
156
78
|
`;
|
|
157
79
|
}
|
|
158
|
-
function genTsconfig() {
|
|
159
|
-
return JSON.stringify(
|
|
160
|
-
{
|
|
161
|
-
compilerOptions: {
|
|
162
|
-
target: "ES2022",
|
|
163
|
-
module: "ES2022",
|
|
164
|
-
moduleResolution: "bundler",
|
|
165
|
-
resolveJsonModule: true,
|
|
166
|
-
esModuleInterop: true,
|
|
167
|
-
strict: true,
|
|
168
|
-
exactOptionalPropertyTypes: true,
|
|
169
|
-
noUnusedLocals: true,
|
|
170
|
-
noUnusedParameters: true,
|
|
171
|
-
noFallthroughCasesInSwitch: true,
|
|
172
|
-
skipLibCheck: true,
|
|
173
|
-
jsx: "preserve",
|
|
174
|
-
jsxImportSource: "react",
|
|
175
|
-
allowImportingTsExtensions: true
|
|
176
|
-
},
|
|
177
|
-
include: ["src", "astro.config.mjs", ".astro/types.d.ts"]
|
|
178
|
-
},
|
|
179
|
-
null,
|
|
180
|
-
2
|
|
181
|
-
) + "\n";
|
|
182
|
-
}
|
|
183
80
|
function genWranglerToml(cfg) {
|
|
184
81
|
const name = slugify(cfg.dir.replace(/^\.\//, "")) || "my-indiepub-site";
|
|
185
82
|
return `name = "${name}"
|
|
@@ -201,10 +98,10 @@ binding = "SESSION"
|
|
|
201
98
|
id = "YOUR_KV_NAMESPACE_ID_HERE"
|
|
202
99
|
`;
|
|
203
100
|
}
|
|
204
|
-
function genNpmrc() {
|
|
101
|
+
function genNpmrc(licenseToken) {
|
|
205
102
|
return [
|
|
206
103
|
"@indiepub:registry=https://registry.indiepub.dev",
|
|
207
|
-
|
|
104
|
+
`//registry.indiepub.dev/:_authToken=${licenseToken}`,
|
|
208
105
|
""
|
|
209
106
|
].join("\n");
|
|
210
107
|
}
|
|
@@ -321,27 +218,20 @@ jobs:
|
|
|
321
218
|
}
|
|
322
219
|
async function scaffold(cfg) {
|
|
323
220
|
const base = cfg.dir;
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
}
|
|
221
|
+
await downloadTemplate(`codeberg:indiepub/themes/${cfg.template}`, {
|
|
222
|
+
dir: base,
|
|
223
|
+
force: true,
|
|
224
|
+
silent: true,
|
|
225
|
+
providers: { codeberg }
|
|
226
|
+
});
|
|
331
227
|
const files = [
|
|
332
|
-
write(base, "package.json", genPackageJson(cfg)),
|
|
333
228
|
write(base, "astro.config.mjs", genAstroConfig(cfg)),
|
|
334
|
-
write(base, "tsconfig.json", genTsconfig()),
|
|
335
229
|
write(base, "wrangler.toml", genWranglerToml(cfg)),
|
|
336
|
-
write(base, ".npmrc", genNpmrc()),
|
|
230
|
+
write(base, ".npmrc", genNpmrc(cfg.licenseToken)),
|
|
337
231
|
write(base, ".gitignore", genGitignore()),
|
|
338
232
|
write(base, ".dev.vars.example", genDevVarsExample(cfg)),
|
|
339
233
|
write(base, ".dev.vars", genDevVars(cfg.licenseToken))
|
|
340
234
|
];
|
|
341
|
-
if (cfg.template === "minimal") {
|
|
342
|
-
files.push(write(base, "src/env.d.ts", `/// <reference types="astro/client" />
|
|
343
|
-
`));
|
|
344
|
-
}
|
|
345
235
|
if (cfg.githubActions) {
|
|
346
236
|
files.push(write(base, ".github/workflows/deploy.yml", genGitHubWorkflow(cfg)));
|
|
347
237
|
}
|