@riebeckite/honox 0.0.10 → 0.0.12
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
CHANGED
|
@@ -132,10 +132,7 @@ async function loadRiebeckiteConfig(options) {
|
|
|
132
132
|
banner: {
|
|
133
133
|
js: 'import { createRequire as __riebeckiteCreateRequire } from "node:module"; const require = __riebeckiteCreateRequire(import.meta.url);'
|
|
134
134
|
},
|
|
135
|
-
plugins: [
|
|
136
|
-
externalizeBareModuleImports(),
|
|
137
|
-
...options.workspaceRoot ? [workspacePackageResolver(options.workspaceRoot)] : []
|
|
138
|
-
]
|
|
135
|
+
plugins: options.workspaceRoot ? [workspacePackageResolver(options.workspaceRoot)] : []
|
|
139
136
|
});
|
|
140
137
|
const module = await import(`${pathToFileUrl(outputFile)}?t=${Date.now()}`);
|
|
141
138
|
return module.default;
|
|
@@ -153,17 +150,6 @@ function resolveHonoxConfig(config, appRoot) {
|
|
|
153
150
|
}
|
|
154
151
|
};
|
|
155
152
|
}
|
|
156
|
-
function externalizeBareModuleImports() {
|
|
157
|
-
return {
|
|
158
|
-
name: "externalize-bare-module-imports",
|
|
159
|
-
setup(buildApi) {
|
|
160
|
-
buildApi.onResolve({ filter: /^[^./]|^\.[^./]|^\.\.$/ }, (args) => {
|
|
161
|
-
if (path2.isAbsolute(args.path)) return null;
|
|
162
|
-
return { path: args.path, external: true };
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
153
|
function pathToFileUrl(filePath) {
|
|
168
154
|
return `file:///${filePath.replace(/\\/g, "/").replace(/^([A-Za-z]):/, "$1:")}`;
|
|
169
155
|
}
|
|
@@ -272,6 +258,145 @@ function isJavaScriptModule(filePath) {
|
|
|
272
258
|
import fs6 from "node:fs/promises";
|
|
273
259
|
import path7 from "node:path";
|
|
274
260
|
|
|
261
|
+
// src/scaffold/deployment.ts
|
|
262
|
+
var GITHUB_REPOSITORY_PATTERN = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
|
|
263
|
+
function assertGitHubRepository(value, option) {
|
|
264
|
+
if (!GITHUB_REPOSITORY_PATTERN.test(value)) {
|
|
265
|
+
throw new Error(
|
|
266
|
+
`${option} must be a GitHub repository in owner/repository form.`
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function deploymentTemplateFiles(options) {
|
|
271
|
+
const contentRepository = options.contentRepository;
|
|
272
|
+
if (contentRepository !== void 0) {
|
|
273
|
+
assertGitHubRepository(contentRepository, "contentRepository");
|
|
274
|
+
}
|
|
275
|
+
if (options.siteRepository !== void 0) {
|
|
276
|
+
assertGitHubRepository(options.siteRepository, "siteRepository");
|
|
277
|
+
}
|
|
278
|
+
if (options.notifyOnContentPush && options.siteRepository === void 0) {
|
|
279
|
+
throw new Error(
|
|
280
|
+
"siteRepository is required when notifyOnContentPush is true."
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
return [
|
|
284
|
+
{ path: "wrangler.jsonc", content: wranglerConfig() },
|
|
285
|
+
{
|
|
286
|
+
path: ".github/workflows/deploy.yml",
|
|
287
|
+
content: deployWorkflow(contentRepository)
|
|
288
|
+
},
|
|
289
|
+
...options.notifyOnContentPush && options.siteRepository !== void 0 ? [
|
|
290
|
+
{
|
|
291
|
+
path: "github/notify-site.yml",
|
|
292
|
+
content: notifySiteWorkflow(options.siteRepository)
|
|
293
|
+
}
|
|
294
|
+
] : []
|
|
295
|
+
];
|
|
296
|
+
}
|
|
297
|
+
function wranglerConfig() {
|
|
298
|
+
return `${JSON.stringify(
|
|
299
|
+
{
|
|
300
|
+
name: "riebeckite-site",
|
|
301
|
+
compatibility_date: "2026-03-10",
|
|
302
|
+
compatibility_flags: ["nodejs_compat"],
|
|
303
|
+
assets: { directory: "./dist" }
|
|
304
|
+
},
|
|
305
|
+
null,
|
|
306
|
+
2
|
|
307
|
+
)}
|
|
308
|
+
`;
|
|
309
|
+
}
|
|
310
|
+
function deployWorkflow(contentRepository) {
|
|
311
|
+
const contentCheckout = contentRepository === void 0 ? "" : `
|
|
312
|
+
- name: Check out the external content repository
|
|
313
|
+
uses: actions/checkout@v4
|
|
314
|
+
with:
|
|
315
|
+
repository: ${contentRepository}
|
|
316
|
+
token: \${{ secrets.RIEBECKITE_CONTENT_READ_TOKEN || github.token }}
|
|
317
|
+
path: content
|
|
318
|
+
`;
|
|
319
|
+
return `name: Deploy to Cloudflare Workers
|
|
320
|
+
|
|
321
|
+
on:
|
|
322
|
+
push:
|
|
323
|
+
branches: [main]
|
|
324
|
+
workflow_dispatch:
|
|
325
|
+
repository_dispatch:
|
|
326
|
+
types: [content-updated]
|
|
327
|
+
|
|
328
|
+
concurrency:
|
|
329
|
+
group: deploy-\${{ github.ref }}
|
|
330
|
+
cancel-in-progress: true
|
|
331
|
+
|
|
332
|
+
jobs:
|
|
333
|
+
deploy:
|
|
334
|
+
runs-on: ubuntu-latest
|
|
335
|
+
permissions:
|
|
336
|
+
contents: read
|
|
337
|
+
steps:
|
|
338
|
+
- name: Check out the site repository
|
|
339
|
+
uses: actions/checkout@v4
|
|
340
|
+
${contentCheckout}
|
|
341
|
+
- name: Set up Node.js
|
|
342
|
+
uses: actions/setup-node@v4
|
|
343
|
+
with:
|
|
344
|
+
node-version: 22
|
|
345
|
+
cache: npm
|
|
346
|
+
|
|
347
|
+
- name: Install dependencies
|
|
348
|
+
run: npm ci
|
|
349
|
+
|
|
350
|
+
- name: Validate configuration and plugins
|
|
351
|
+
run: npm exec riebeckite check
|
|
352
|
+
|
|
353
|
+
- name: Build the site
|
|
354
|
+
run: npm exec riebeckite build
|
|
355
|
+
|
|
356
|
+
- name: Deploy the built assets
|
|
357
|
+
uses: cloudflare/wrangler-action@v3
|
|
358
|
+
with:
|
|
359
|
+
apiToken: \${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
360
|
+
accountId: \${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
361
|
+
command: deploy
|
|
362
|
+
`;
|
|
363
|
+
}
|
|
364
|
+
function notifySiteWorkflow(siteRepository) {
|
|
365
|
+
const [owner, repo] = siteRepository.split("/");
|
|
366
|
+
return `name: Notify Riebeckite site
|
|
367
|
+
|
|
368
|
+
on:
|
|
369
|
+
push:
|
|
370
|
+
branches: [main]
|
|
371
|
+
|
|
372
|
+
permissions: {}
|
|
373
|
+
|
|
374
|
+
jobs:
|
|
375
|
+
notify:
|
|
376
|
+
runs-on: ubuntu-latest
|
|
377
|
+
steps:
|
|
378
|
+
- name: Validate dispatch configuration
|
|
379
|
+
env:
|
|
380
|
+
SITE_DISPATCH_TOKEN: \${{ secrets.SITE_DISPATCH_TOKEN }}
|
|
381
|
+
run: |
|
|
382
|
+
if [ -z "$SITE_DISPATCH_TOKEN" ]; then
|
|
383
|
+
echo "::error::SITE_DISPATCH_TOKEN is not configured. Add a token that can dispatch to ${siteRepository}."
|
|
384
|
+
exit 1
|
|
385
|
+
fi
|
|
386
|
+
|
|
387
|
+
- name: Notify the site repository
|
|
388
|
+
uses: actions/github-script@v7
|
|
389
|
+
with:
|
|
390
|
+
github-token: \${{ secrets.SITE_DISPATCH_TOKEN }}
|
|
391
|
+
script: |
|
|
392
|
+
await github.rest.repos.createDispatchEvent({
|
|
393
|
+
owner: ${JSON.stringify(owner)},
|
|
394
|
+
repo: ${JSON.stringify(repo)},
|
|
395
|
+
event_type: "content-updated",
|
|
396
|
+
});
|
|
397
|
+
`;
|
|
398
|
+
}
|
|
399
|
+
|
|
275
400
|
// src/scaffold/presets.ts
|
|
276
401
|
var SCAFFOLD_LANGUAGES = [
|
|
277
402
|
"en",
|
|
@@ -3209,7 +3334,7 @@ function referenceThemesContent(preset) {
|
|
|
3209
3334
|
}
|
|
3210
3335
|
|
|
3211
3336
|
// src/scaffold/version.ts
|
|
3212
|
-
var RIEBECKITE_VERSION = "^0.0.
|
|
3337
|
+
var RIEBECKITE_VERSION = "^0.0.12";
|
|
3213
3338
|
|
|
3214
3339
|
// src/scaffold/templates.ts
|
|
3215
3340
|
function siteTemplateFiles(preset, variables) {
|
|
@@ -4100,10 +4225,11 @@ var ScaffoldSiteError = class extends Error {
|
|
|
4100
4225
|
async function scaffoldRiebeckiteSite(options) {
|
|
4101
4226
|
const targetDirectory = path7.resolve(options.targetDirectory);
|
|
4102
4227
|
const preset = resolveScaffoldPreset(options.preset);
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
templateVariables(options, targetDirectory)
|
|
4106
|
-
|
|
4228
|
+
validateDeploymentOptions(options);
|
|
4229
|
+
const files = [
|
|
4230
|
+
...siteTemplateFiles(preset, templateVariables(options, targetDirectory)),
|
|
4231
|
+
...options.githubActions ? deploymentTemplateFiles(deploymentOptions(options)) : []
|
|
4232
|
+
];
|
|
4107
4233
|
await assertTargetWritable(
|
|
4108
4234
|
targetDirectory,
|
|
4109
4235
|
files,
|
|
@@ -4116,6 +4242,43 @@ async function scaffoldRiebeckiteSite(options) {
|
|
|
4116
4242
|
}
|
|
4117
4243
|
return { targetDirectory, files: files.map((file) => file.path) };
|
|
4118
4244
|
}
|
|
4245
|
+
function deploymentOptions(options) {
|
|
4246
|
+
return {
|
|
4247
|
+
contentRepository: options.contentRepository,
|
|
4248
|
+
siteRepository: options.siteRepository,
|
|
4249
|
+
notifyOnContentPush: options.notifyOnContentPush
|
|
4250
|
+
};
|
|
4251
|
+
}
|
|
4252
|
+
function validateDeploymentOptions(options) {
|
|
4253
|
+
try {
|
|
4254
|
+
if (options.contentRepository !== void 0) {
|
|
4255
|
+
assertGitHubRepository(options.contentRepository, "contentRepository");
|
|
4256
|
+
}
|
|
4257
|
+
if (options.siteRepository !== void 0) {
|
|
4258
|
+
assertGitHubRepository(options.siteRepository, "siteRepository");
|
|
4259
|
+
}
|
|
4260
|
+
} catch (error) {
|
|
4261
|
+
throw new ScaffoldSiteError(
|
|
4262
|
+
error instanceof Error ? error.message : String(error)
|
|
4263
|
+
);
|
|
4264
|
+
}
|
|
4265
|
+
if (options.contentRepository !== void 0 && !options.githubActions) {
|
|
4266
|
+
throw new ScaffoldSiteError(
|
|
4267
|
+
"contentRepository requires githubActions to generate its checkout workflow."
|
|
4268
|
+
);
|
|
4269
|
+
}
|
|
4270
|
+
if (options.notifyOnContentPush && !options.githubActions) {
|
|
4271
|
+
throw new ScaffoldSiteError("notifyOnContentPush requires githubActions.");
|
|
4272
|
+
}
|
|
4273
|
+
if (options.notifyOnContentPush && options.contentRepository === void 0) {
|
|
4274
|
+
throw new ScaffoldSiteError(
|
|
4275
|
+
"notifyOnContentPush requires contentRepository."
|
|
4276
|
+
);
|
|
4277
|
+
}
|
|
4278
|
+
if (options.notifyOnContentPush && options.siteRepository === void 0) {
|
|
4279
|
+
throw new ScaffoldSiteError("notifyOnContentPush requires siteRepository.");
|
|
4280
|
+
}
|
|
4281
|
+
}
|
|
4119
4282
|
function templateVariables(options, targetDirectory) {
|
|
4120
4283
|
const name = normalizePackageName(
|
|
4121
4284
|
options.name ?? path7.basename(targetDirectory)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SiteTemplateFile } from "./templates.js";
|
|
2
|
+
export type ScaffoldDeploymentOptions = {
|
|
3
|
+
readonly contentRepository?: string;
|
|
4
|
+
readonly siteRepository?: string;
|
|
5
|
+
readonly notifyOnContentPush?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function assertGitHubRepository(value: string, option: string): void;
|
|
8
|
+
export declare function deploymentTemplateFiles(options: ScaffoldDeploymentOptions): readonly SiteTemplateFile[];
|
|
@@ -8,6 +8,14 @@ export type ScaffoldSiteOptions = {
|
|
|
8
8
|
readonly locale?: string;
|
|
9
9
|
readonly preset?: ScaffoldPresetName | ScaffoldPreset;
|
|
10
10
|
readonly overwrite?: boolean;
|
|
11
|
+
/** Generate the Cloudflare Workers GitHub Actions workflow. */
|
|
12
|
+
readonly githubActions?: boolean;
|
|
13
|
+
/** Read content from this separate GitHub repository during deployment. */
|
|
14
|
+
readonly contentRepository?: string;
|
|
15
|
+
/** Site repository to notify from the generated content workflow. */
|
|
16
|
+
readonly siteRepository?: string;
|
|
17
|
+
/** Generate a content-repository workflow that dispatches after a push. */
|
|
18
|
+
readonly notifyOnContentPush?: boolean;
|
|
11
19
|
};
|
|
12
20
|
export type ScaffoldSiteResult = {
|
|
13
21
|
readonly targetDirectory: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const RIEBECKITE_VERSION = "^0.0.
|
|
1
|
+
export declare const RIEBECKITE_VERSION = "^0.0.12";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/honox",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"esbuild": "^0.28.2",
|
|
37
37
|
"hono": "^4.12.25",
|
|
38
38
|
"vite": "^8.0.9",
|
|
39
|
-
"@riebeckite/core": "0.0.
|
|
39
|
+
"@riebeckite/core": "0.0.12"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
},
|
|
69
69
|
"sideEffects": false,
|
|
70
70
|
"scripts": {
|
|
71
|
-
"build": "node ../../../scripts/build_package.mjs"
|
|
71
|
+
"build": "node ../../../scripts/build_package.mjs",
|
|
72
|
+
"test": "node --import tsx --test \"test/*.test.ts\""
|
|
72
73
|
}
|
|
73
74
|
}
|