mnfst-publish 0.1.7 → 0.1.8
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/bin/mnfst-publish.js +0 -0
- package/manifest.publish.mjs +25 -3
- package/package.json +1 -1
package/bin/mnfst-publish.js
CHANGED
|
File without changes
|
package/manifest.publish.mjs
CHANGED
|
@@ -30,6 +30,7 @@ function parseArgs(argv) {
|
|
|
30
30
|
else if (a === '--production' || a === '--prod') out.env = 'production';
|
|
31
31
|
else if (a === '--env') out.env = argv[++i];
|
|
32
32
|
else if (a === '--source') out.source = argv[++i];
|
|
33
|
+
else if (a === '--output-dir') out.outputDir = argv[++i];
|
|
33
34
|
else if (a === '--no-render') out.render = false;
|
|
34
35
|
else if (a === '--render') out.render = true;
|
|
35
36
|
else if (a === '--promote') out.promote = true;
|
|
@@ -259,11 +260,29 @@ export function loadPublishIgnore(root) {
|
|
|
259
260
|
return makePublishIgnore(patterns);
|
|
260
261
|
}
|
|
261
262
|
|
|
262
|
-
export function collectFiles(root) {
|
|
263
|
+
export function collectFiles(root, outputDir) {
|
|
263
264
|
const git = spawnSync('git', ['ls-files', '-co', '--exclude-standard'], { cwd: root, encoding: 'utf8' });
|
|
264
265
|
let rels;
|
|
265
266
|
if (git.status === 0) {
|
|
266
267
|
rels = git.stdout.split('\n').map((s) => s.trim()).filter(Boolean);
|
|
268
|
+
// Non-Manifest builds usually write to a GITIGNORED folder (dist/, build/…)
|
|
269
|
+
// — force-include the declared output dir or the publish ships no site.
|
|
270
|
+
if (outputDir && existsSync(join(root, outputDir))) {
|
|
271
|
+
const seen = new Set(rels);
|
|
272
|
+
const walkOut = (dir) => {
|
|
273
|
+
for (const name of readdirSync(dir)) {
|
|
274
|
+
if (EXCLUDED_DIRS.has(name)) continue;
|
|
275
|
+
const abs = join(dir, name);
|
|
276
|
+
const st = statSync(abs);
|
|
277
|
+
if (st.isDirectory()) walkOut(abs);
|
|
278
|
+
else {
|
|
279
|
+
const rel = relative(root, abs).split(sep).join('/');
|
|
280
|
+
if (!seen.has(rel)) { seen.add(rel); rels.push(rel); }
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
walkOut(join(root, outputDir));
|
|
285
|
+
}
|
|
267
286
|
} else {
|
|
268
287
|
// Not a git repo — walk, skipping excluded dirs as we go.
|
|
269
288
|
rels = [];
|
|
@@ -403,7 +422,7 @@ function buildZip(root, rels, overrides = new Map()) {
|
|
|
403
422
|
export async function main() {
|
|
404
423
|
const opts = parseArgs(process.argv.slice(2));
|
|
405
424
|
if (opts.help) {
|
|
406
|
-
log('Usage: npx mnfst-publish [--staging|--production] [--no-render] [--promote]');
|
|
425
|
+
log('Usage: npx mnfst-publish [--staging|--production] [--source spa|render] [--output-dir <dir>] [--no-render] [--promote]');
|
|
407
426
|
log('Publishes the current Manifest project to managed hosting and prints the live URL.');
|
|
408
427
|
return;
|
|
409
428
|
}
|
|
@@ -484,8 +503,11 @@ export async function main() {
|
|
|
484
503
|
fail('the upload URL returned by the server was malformed.');
|
|
485
504
|
}
|
|
486
505
|
|
|
487
|
-
const rels = collectFiles(root);
|
|
506
|
+
const rels = collectFiles(root, opts.outputDir);
|
|
488
507
|
if (!rels.length) fail('nothing to publish (no files found).');
|
|
508
|
+
if (opts.outputDir && !existsSync(join(root, opts.outputDir))) {
|
|
509
|
+
fail(`the output folder "${opts.outputDir}" doesn't exist — run the project's build first, then publish again.`);
|
|
510
|
+
}
|
|
489
511
|
const zip = buildZip(root, rels, stampManifests(root, rels));
|
|
490
512
|
log(`Uploading ${rels.length} files (${(zip.length / 1048576).toFixed(1)} MB)…`);
|
|
491
513
|
|