@couch-kit/cli 0.2.0 → 0.2.2
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 +29 -5
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1932,11 +1932,24 @@ __export(exports_bundle, {
|
|
|
1932
1932
|
import fs from "node:fs";
|
|
1933
1933
|
import path from "node:path";
|
|
1934
1934
|
import { execSync } from "node:child_process";
|
|
1935
|
+
function collectFiles(dir, prefix = "") {
|
|
1936
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
1937
|
+
const files = [];
|
|
1938
|
+
for (const entry of entries) {
|
|
1939
|
+
const relativePath = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
1940
|
+
if (entry.isDirectory()) {
|
|
1941
|
+
files.push(...collectFiles(path.join(dir, entry.name), relativePath));
|
|
1942
|
+
} else {
|
|
1943
|
+
files.push(relativePath);
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
return files;
|
|
1947
|
+
}
|
|
1935
1948
|
var bundleCommand;
|
|
1936
1949
|
var init_bundle = __esm(() => {
|
|
1937
1950
|
init_esm();
|
|
1938
1951
|
init_src();
|
|
1939
|
-
bundleCommand = new Command("bundle").description("Bundles the web controller into the Android assets directory").option("-s, --source <path>", "Source directory of web controller", "./web-controller").option("-o, --output <path>", "Android assets directory", "./android/app/src/main/assets/www").option("--no-build", "Skip build step (just copy)").action(async (options) => {
|
|
1952
|
+
bundleCommand = new Command("bundle").description("Bundles the web controller into the Android assets directory").option("-s, --source <path>", "Source directory of web controller", "./web-controller").option("-o, --output <path>", "Android assets directory", "./android/app/src/main/assets/www").option("--no-build", "Skip build step (just copy)").option("-m, --manifest <path>", "Also write manifest to this path for import in app source").action(async (options) => {
|
|
1940
1953
|
console.log("Bundling controller...");
|
|
1941
1954
|
try {
|
|
1942
1955
|
const sourceDir = path.resolve(process.cwd(), options.source);
|
|
@@ -1958,6 +1971,19 @@ var init_bundle = __esm(() => {
|
|
|
1958
1971
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
1959
1972
|
console.log(" Copying assets...");
|
|
1960
1973
|
fs.cpSync(distDir, targetDir, { recursive: true });
|
|
1974
|
+
const files = collectFiles(targetDir).sort();
|
|
1975
|
+
const manifest = JSON.stringify({ files }, null, 2);
|
|
1976
|
+
const manifestPath = path.join(targetDir, "www-manifest.json");
|
|
1977
|
+
fs.writeFileSync(manifestPath, manifest + `
|
|
1978
|
+
`);
|
|
1979
|
+
console.log(` Generated manifest with ${files.length} files`);
|
|
1980
|
+
if (options.manifest) {
|
|
1981
|
+
const secondaryPath = path.resolve(process.cwd(), options.manifest);
|
|
1982
|
+
fs.mkdirSync(path.dirname(secondaryPath), { recursive: true });
|
|
1983
|
+
fs.writeFileSync(secondaryPath, manifest + `
|
|
1984
|
+
`);
|
|
1985
|
+
console.log(` Manifest also written to ${options.manifest}`);
|
|
1986
|
+
}
|
|
1961
1987
|
console.log(`Done! Controller bundled to ${options.output}`);
|
|
1962
1988
|
} catch (e) {
|
|
1963
1989
|
console.error(`Bundle failed: ${toErrorMessage(e)}`);
|
|
@@ -2182,7 +2208,7 @@ var require2 = createRequire2(import.meta.url);
|
|
|
2182
2208
|
var { version } = require2("../package.json");
|
|
2183
2209
|
var program2 = new Command;
|
|
2184
2210
|
program2.name("couch-kit").description("CLI for Couch Kit").version(version);
|
|
2185
|
-
program2.command("bundle").description("Bundles the web controller into the Android assets directory").option("-s, --source <path>", "Source directory of web controller", "./web-controller").option("-o, --output <path>", "Android assets directory", "./android/app/src/main/assets/www").option("--no-build", "Skip build step (just copy)").action(async (options) => {
|
|
2211
|
+
program2.command("bundle").description("Bundles the web controller into the Android assets directory").option("-s, --source <path>", "Source directory of web controller", "./web-controller").option("-o, --output <path>", "Android assets directory", "./android/app/src/main/assets/www").option("--no-build", "Skip build step (just copy)").option("-m, --manifest <path>", "Also write manifest to this path for import in app source").action(async (options) => {
|
|
2186
2212
|
const { bundleCommand: bundleCommand2 } = await Promise.resolve().then(() => (init_bundle(), exports_bundle));
|
|
2187
2213
|
await bundleCommand2.parseAsync(["bundle", ...reconstructArgs(options)], {
|
|
2188
2214
|
from: "user"
|
|
@@ -2200,9 +2226,7 @@ function reconstructArgs(options) {
|
|
|
2200
2226
|
const args = [];
|
|
2201
2227
|
for (const [key, value] of Object.entries(options)) {
|
|
2202
2228
|
if (typeof value === "boolean") {
|
|
2203
|
-
if (value)
|
|
2204
|
-
args.push(`--${key}`);
|
|
2205
|
-
else
|
|
2229
|
+
if (!value)
|
|
2206
2230
|
args.push(`--no-${key}`);
|
|
2207
2231
|
} else if (value !== undefined) {
|
|
2208
2232
|
args.push(`--${key}`, String(value));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@couch-kit/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "CLI tools for Couch Kit party games — bundle web controllers, simulate clients, and scaffold projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"clean": "rm -rf dist"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@couch-kit/core": "0.
|
|
34
|
+
"@couch-kit/core": "0.4.0",
|
|
35
35
|
"commander": "^12.0.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|