@plotpaper/cli 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/bin/plotpaper.js +2 -0
- package/dist/bundler/index.d.ts +17 -0
- package/dist/bundler/index.js +53 -0
- package/dist/bundler/index.js.map +1 -0
- package/dist/bundler/rewrite.d.ts +13 -0
- package/dist/bundler/rewrite.js +93 -0
- package/dist/bundler/rewrite.js.map +1 -0
- package/dist/bundler/transform.d.ts +7 -0
- package/dist/bundler/transform.js +66 -0
- package/dist/bundler/transform.js.map +1 -0
- package/dist/bundler/wrap.d.ts +6 -0
- package/dist/bundler/wrap.js +21 -0
- package/dist/bundler/wrap.js.map +1 -0
- package/dist/commands/bundle.d.ts +6 -0
- package/dist/commands/bundle.js +97 -0
- package/dist/commands/bundle.js.map +1 -0
- package/dist/commands/submit.d.ts +8 -0
- package/dist/commands/submit.js +114 -0
- package/dist/commands/submit.js.map +1 -0
- package/dist/commands/validate.d.ts +4 -0
- package/dist/commands/validate.js +97 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/api.d.ts +15 -0
- package/dist/utils/api.js +56 -0
- package/dist/utils/api.js.map +1 -0
- package/dist/utils/config.d.ts +9 -0
- package/dist/utils/config.js +73 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/validation/imports.d.ts +5 -0
- package/dist/validation/imports.js +33 -0
- package/dist/validation/imports.js.map +1 -0
- package/dist/validation/index.d.ts +27 -0
- package/dist/validation/index.js +79 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/patterns.d.ts +8 -0
- package/dist/validation/patterns.js +38 -0
- package/dist/validation/patterns.js.map +1 -0
- package/dist/validation/schema.d.ts +209 -0
- package/dist/validation/schema.js +181 -0
- package/dist/validation/schema.js.map +1 -0
- package/package.json +32 -0
package/bin/plotpaper.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { transformSource } from "./transform";
|
|
2
|
+
export { stripComments, rewriteImportsExports } from "./rewrite";
|
|
3
|
+
export { wrapInIIFE } from "./wrap";
|
|
4
|
+
/**
|
|
5
|
+
* Bundle raw source code into an IIFE string.
|
|
6
|
+
*
|
|
7
|
+
* Pipeline:
|
|
8
|
+
* 1. esbuild transform (JSX, async/await, ES2016)
|
|
9
|
+
* 2. Strip comments
|
|
10
|
+
* 3. Rewrite imports/exports to __ppModules lookups
|
|
11
|
+
* 4. Wrap in IIFE with component registration
|
|
12
|
+
*
|
|
13
|
+
* @param source Raw .tsx source code
|
|
14
|
+
* @param bundleId Unique bundle identifier
|
|
15
|
+
* @returns Bundled IIFE string
|
|
16
|
+
*/
|
|
17
|
+
export declare function bundle(source: string, bundleId: string): Promise<string>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// =============================================================================
|
|
3
|
+
// Bundler — full pipeline from source to IIFE
|
|
4
|
+
// =============================================================================
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.wrapInIIFE = exports.rewriteImportsExports = exports.stripComments = exports.transformSource = void 0;
|
|
7
|
+
exports.bundle = bundle;
|
|
8
|
+
const transform_1 = require("./transform");
|
|
9
|
+
const rewrite_1 = require("./rewrite");
|
|
10
|
+
const wrap_1 = require("./wrap");
|
|
11
|
+
var transform_2 = require("./transform");
|
|
12
|
+
Object.defineProperty(exports, "transformSource", { enumerable: true, get: function () { return transform_2.transformSource; } });
|
|
13
|
+
var rewrite_2 = require("./rewrite");
|
|
14
|
+
Object.defineProperty(exports, "stripComments", { enumerable: true, get: function () { return rewrite_2.stripComments; } });
|
|
15
|
+
Object.defineProperty(exports, "rewriteImportsExports", { enumerable: true, get: function () { return rewrite_2.rewriteImportsExports; } });
|
|
16
|
+
var wrap_2 = require("./wrap");
|
|
17
|
+
Object.defineProperty(exports, "wrapInIIFE", { enumerable: true, get: function () { return wrap_2.wrapInIIFE; } });
|
|
18
|
+
/**
|
|
19
|
+
* Bundle raw source code into an IIFE string.
|
|
20
|
+
*
|
|
21
|
+
* Pipeline:
|
|
22
|
+
* 1. esbuild transform (JSX, async/await, ES2016)
|
|
23
|
+
* 2. Strip comments
|
|
24
|
+
* 3. Rewrite imports/exports to __ppModules lookups
|
|
25
|
+
* 4. Wrap in IIFE with component registration
|
|
26
|
+
*
|
|
27
|
+
* @param source Raw .tsx source code
|
|
28
|
+
* @param bundleId Unique bundle identifier
|
|
29
|
+
* @returns Bundled IIFE string
|
|
30
|
+
*/
|
|
31
|
+
async function bundle(source, bundleId) {
|
|
32
|
+
// Step 1: Transpile
|
|
33
|
+
const transformed = await (0, transform_1.transformSource)(source);
|
|
34
|
+
// Step 2: Strip comments
|
|
35
|
+
const stripped = (0, rewrite_1.stripComments)(transformed);
|
|
36
|
+
// Step 3: Rewrite imports/exports
|
|
37
|
+
const { code: rewritten, defaultExportName } = (0, rewrite_1.rewriteImportsExports)(stripped);
|
|
38
|
+
if (!defaultExportName) {
|
|
39
|
+
throw new Error("No default export found in source code");
|
|
40
|
+
}
|
|
41
|
+
// Post-rewrite validation
|
|
42
|
+
const remainingImport = rewritten.match(/\bimport\s+(?:\w|\{|\*).*\s+from\s+["'][^"']+["']/);
|
|
43
|
+
if (remainingImport) {
|
|
44
|
+
throw new Error(`Unrewritten import found after bundling: ${remainingImport[0]}`);
|
|
45
|
+
}
|
|
46
|
+
const remainingExportDefault = rewritten.match(/\bexport\s+default\b/);
|
|
47
|
+
if (remainingExportDefault) {
|
|
48
|
+
throw new Error("Unrewritten 'export default' found after bundling");
|
|
49
|
+
}
|
|
50
|
+
// Step 4: Wrap in IIFE
|
|
51
|
+
return (0, wrap_1.wrapInIIFE)(rewritten, bundleId, defaultExportName);
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bundler/index.ts"],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
|
|
|
1
|
+
/**
|
|
2
|
+
* Strip single-line and multi-line comments from code.
|
|
3
|
+
* Preserves strings and template literals.
|
|
4
|
+
*/
|
|
5
|
+
export declare function stripComments(code: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Rewrite ES import/export statements to globalThis.__ppModules lookups.
|
|
8
|
+
* Returns the rewritten code and the captured default export name.
|
|
9
|
+
*/
|
|
10
|
+
export declare function rewriteImportsExports(code: string): {
|
|
11
|
+
code: string;
|
|
12
|
+
defaultExportName: string | null;
|
|
13
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// =============================================================================
|
|
3
|
+
// Import/Export Rewriting — ported from plotpaper-aws bundler.ts
|
|
4
|
+
// =============================================================================
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.stripComments = stripComments;
|
|
7
|
+
exports.rewriteImportsExports = rewriteImportsExports;
|
|
8
|
+
const SHARED_MODULES = [
|
|
9
|
+
"react",
|
|
10
|
+
"react-native",
|
|
11
|
+
"@plotpaper/mini-app-sdk",
|
|
12
|
+
"@expo/vector-icons/Feather",
|
|
13
|
+
"react-native-svg",
|
|
14
|
+
"react-native-safe-area-context",
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* Strip single-line and multi-line comments from code.
|
|
18
|
+
* Preserves strings and template literals.
|
|
19
|
+
*/
|
|
20
|
+
function stripComments(code) {
|
|
21
|
+
return code.replace(/("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`)|\/\/[^\n]*|\/\*[\s\S]*?\*\//g, (match, stringLiteral) => {
|
|
22
|
+
return stringLiteral || "";
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Convert ES import aliases (as) to destructuring aliases (:).
|
|
27
|
+
*/
|
|
28
|
+
function importAliasesToDestructuring(names) {
|
|
29
|
+
return names.replace(/(\w+)\s+as\s+(\w+)/g, "$1: $2");
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Rewrite ES import/export statements to globalThis.__ppModules lookups.
|
|
33
|
+
* Returns the rewritten code and the captured default export name.
|
|
34
|
+
*/
|
|
35
|
+
function rewriteImportsExports(code) {
|
|
36
|
+
let result = code;
|
|
37
|
+
let defaultExportName = null;
|
|
38
|
+
// import DefaultName, { A, B } from "module" (must come first)
|
|
39
|
+
result = result.replace(/import\s+(\w+)\s*,\s*\{([^}]+)\}\s+from\s+["']([^"']+)["']\s*;?/g, (_match, defaultName, names, mod) => {
|
|
40
|
+
if (SHARED_MODULES.includes(mod)) {
|
|
41
|
+
const m = JSON.stringify(mod);
|
|
42
|
+
const destructured = importAliasesToDestructuring(names).replace(/\s/g, "");
|
|
43
|
+
return `var ${defaultName}=__m[${m}].default||__m[${m}];var{${destructured}}=__m[${m}];`;
|
|
44
|
+
}
|
|
45
|
+
return _match;
|
|
46
|
+
});
|
|
47
|
+
// import * as Name from "module"
|
|
48
|
+
result = result.replace(/import\s+\*\s+as\s+(\w+)\s+from\s+["']([^"']+)["']\s*;?/g, (_match, name, mod) => {
|
|
49
|
+
if (SHARED_MODULES.includes(mod)) {
|
|
50
|
+
return `var ${name}=__m[${JSON.stringify(mod)}];`;
|
|
51
|
+
}
|
|
52
|
+
return _match;
|
|
53
|
+
});
|
|
54
|
+
// import { A, B } from "module"
|
|
55
|
+
result = result.replace(/import\s+\{([^}]+)\}\s+from\s+["']([^"']+)["']\s*;?/g, (_match, names, mod) => {
|
|
56
|
+
if (SHARED_MODULES.includes(mod)) {
|
|
57
|
+
const destructured = importAliasesToDestructuring(names).replace(/\s+/g, " ");
|
|
58
|
+
return `var{${destructured}}=__m[${JSON.stringify(mod)}];`;
|
|
59
|
+
}
|
|
60
|
+
return _match;
|
|
61
|
+
});
|
|
62
|
+
// import DefaultName from "module"
|
|
63
|
+
result = result.replace(/import\s+(\w+)\s+from\s+["']([^"']+)["']\s*;?/g, (_match, name, mod) => {
|
|
64
|
+
if (SHARED_MODULES.includes(mod)) {
|
|
65
|
+
const m = JSON.stringify(mod);
|
|
66
|
+
return `var ${name}=__m[${m}].default||__m[${m}];`;
|
|
67
|
+
}
|
|
68
|
+
return _match;
|
|
69
|
+
});
|
|
70
|
+
// export default function Name(...)
|
|
71
|
+
const exportDefaultFnMatch = result.match(/export\s+default\s+function\s+(\w+)/);
|
|
72
|
+
if (exportDefaultFnMatch) {
|
|
73
|
+
defaultExportName = exportDefaultFnMatch[1];
|
|
74
|
+
result = result.replace(/export\s+default\s+function\s+/, "function ");
|
|
75
|
+
}
|
|
76
|
+
// export default function(...) — anonymous
|
|
77
|
+
if (!defaultExportName && /export\s+default\s+function\s*\(/.test(result)) {
|
|
78
|
+
defaultExportName = "__PPDefaultComponent";
|
|
79
|
+
result = result.replace(/export\s+default\s+function\s*\(/, `function ${defaultExportName}(`);
|
|
80
|
+
}
|
|
81
|
+
// export default Name;
|
|
82
|
+
if (!defaultExportName) {
|
|
83
|
+
const exportDefaultIdMatch = result.match(/export\s+default\s+(\w+)\s*;?/);
|
|
84
|
+
if (exportDefaultIdMatch) {
|
|
85
|
+
defaultExportName = exportDefaultIdMatch[1];
|
|
86
|
+
result = result.replace(/export\s+default\s+\w+\s*;?/, "");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Remove named export keywords
|
|
90
|
+
result = result.replace(/export\s+(?=const |let |var |function |class )/g, "");
|
|
91
|
+
return { code: result, defaultExportName };
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=rewrite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rewrite.js","sourceRoot":"","sources":["../../src/bundler/rewrite.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,iEAAiE;AACjE,gFAAgF;;AAehF,sCAOC;AAaD,sDA8EC;AA/GD,MAAM,cAAc,GAAG;IACrB,OAAO;IACP,cAAc;IACd,yBAAyB;IACzB,4BAA4B;IAC5B,kBAAkB;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AAG,sBAAsB,CAAC;QAC3C,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,kCAAkC,EAAE,YAAY,iBAAiB,GAAG,CAAC,CAAC;IAChG,CAAC;IAED,uBAAuB;IACvB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,MAAM,oBAAoB,GAAG,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAC3E,IAAI,oBAAoB,EAAE,CAAC;YACzB,iBAAiB,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC;YAC5C,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAED,+BAA+B;IAC/B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,iDAAiD,EAAE,EAAE,CAAC,CAAC;IAE/E,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// =============================================================================
|
|
3
|
+
// esbuild Transform Step
|
|
4
|
+
// =============================================================================
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.transformSource = transformSource;
|
|
40
|
+
const esbuild = __importStar(require("esbuild-wasm"));
|
|
41
|
+
let esbuildReady = false;
|
|
42
|
+
async function ensureEsbuild() {
|
|
43
|
+
if (!esbuildReady) {
|
|
44
|
+
await esbuild.initialize({ worker: false });
|
|
45
|
+
esbuildReady = true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Transpile source code using esbuild:
|
|
50
|
+
* - JSX → React.createElement
|
|
51
|
+
* - async/await → generators
|
|
52
|
+
* - Target ES2016 (Hermes compatible)
|
|
53
|
+
*/
|
|
54
|
+
async function transformSource(source) {
|
|
55
|
+
await ensureEsbuild();
|
|
56
|
+
const result = await esbuild.transform(source, {
|
|
57
|
+
loader: "tsx",
|
|
58
|
+
jsx: "transform",
|
|
59
|
+
jsxFactory: "React.createElement",
|
|
60
|
+
jsxFragment: "React.Fragment",
|
|
61
|
+
target: "es2016",
|
|
62
|
+
charset: "utf8",
|
|
63
|
+
});
|
|
64
|
+
return result.code;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/bundler/transform.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yBAAyB;AACzB,gFAAgF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBhF,0CAaC;AA9BD,sDAAwC;AAExC,IAAI,YAAY,GAAG,KAAK,CAAC;AAEzB,KAAK,UAAU,aAAa;IAC1B,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,OAAO,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5C,YAAY,GAAG,IAAI,CAAC;IACtB,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,eAAe,CAAC,MAAc;IAClD,MAAM,aAAa,EAAE,CAAC;IAEtB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE;QAC7C,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,WAAW;QAChB,UAAU,EAAE,qBAAqB;QACjC,WAAW,EAAE,gBAAgB;QAC7B,MAAM,EAAE,QAAQ;QAChB,OAAO,EAAE,MAAM;KAChB,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrap rewritten code in a self-executing function that:
|
|
3
|
+
* 1. Sets up module registry access (__m = globalThis.__ppModules)
|
|
4
|
+
* 2. Registers the default export on globalThis.__ppMiniApps[bundleId]
|
|
5
|
+
*/
|
|
6
|
+
export declare function wrapInIIFE(code: string, bundleId: string, defaultExportName: string): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// =============================================================================
|
|
3
|
+
// IIFE Wrapping
|
|
4
|
+
// =============================================================================
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.wrapInIIFE = wrapInIIFE;
|
|
7
|
+
/**
|
|
8
|
+
* Wrap rewritten code in a self-executing function that:
|
|
9
|
+
* 1. Sets up module registry access (__m = globalThis.__ppModules)
|
|
10
|
+
* 2. Registers the default export on globalThis.__ppMiniApps[bundleId]
|
|
11
|
+
*/
|
|
12
|
+
function wrapInIIFE(code, bundleId, defaultExportName) {
|
|
13
|
+
return `(function(){
|
|
14
|
+
"use strict";
|
|
15
|
+
var __m=globalThis.__ppModules;
|
|
16
|
+
${code}
|
|
17
|
+
globalThis.__ppMiniApps=globalThis.__ppMiniApps||{};
|
|
18
|
+
globalThis.__ppMiniApps[${JSON.stringify(bundleId)}]=${defaultExportName};
|
|
19
|
+
})();`;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=wrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrap.js","sourceRoot":"","sources":["../../src/bundler/wrap.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,gBAAgB;AAChB,gFAAgF;;AAOhF,gCAQC;AAbD;;;;GAIG;AACH,SAAgB,UAAU,CAAC,IAAY,EAAE,QAAgB,EAAE,iBAAyB;IAClF,OAAO;;;EAGP,IAAI;;0BAEoB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,iBAAiB;MAClE,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// =============================================================================
|
|
3
|
+
// bundle command — compile source to IIFE bundle
|
|
4
|
+
// =============================================================================
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.runBundle = runBundle;
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
45
|
+
const crypto = __importStar(require("crypto"));
|
|
46
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
47
|
+
const validation_1 = require("../validation");
|
|
48
|
+
const bundler_1 = require("../bundler");
|
|
49
|
+
async function runBundle(filePath, options) {
|
|
50
|
+
const resolved = path.resolve(filePath);
|
|
51
|
+
if (!fs.existsSync(resolved)) {
|
|
52
|
+
console.error(chalk_1.default.red(`File not found: ${resolved}`));
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
const source = fs.readFileSync(resolved, "utf-8");
|
|
56
|
+
// Validate first
|
|
57
|
+
console.log();
|
|
58
|
+
console.log(chalk_1.default.bold(`Bundling ${path.basename(resolved)}`));
|
|
59
|
+
const validation = (0, validation_1.validateSource)(source, {
|
|
60
|
+
filePath: resolved,
|
|
61
|
+
schemaPath: options.schema,
|
|
62
|
+
});
|
|
63
|
+
if (!validation.valid) {
|
|
64
|
+
console.log(chalk_1.default.red.bold(`\n Validation failed:`));
|
|
65
|
+
for (const err of validation.errors) {
|
|
66
|
+
console.log(chalk_1.default.red(` ✗ ${err}`));
|
|
67
|
+
}
|
|
68
|
+
console.log(chalk_1.default.dim(`\n Run 'plotpaper validate ${filePath}' for details.`));
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
// Generate bundle ID if not provided
|
|
72
|
+
const bundleId = options.bundleId || crypto.randomUUID();
|
|
73
|
+
try {
|
|
74
|
+
const bundled = await (0, bundler_1.bundle)(source, bundleId);
|
|
75
|
+
// Validate bundle size
|
|
76
|
+
const bundleCheck = (0, validation_1.validateBundle)(bundled);
|
|
77
|
+
if (!bundleCheck.valid) {
|
|
78
|
+
console.error(chalk_1.default.red(`\n ${bundleCheck.error}`));
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
// Write output
|
|
82
|
+
const outputPath = options.output
|
|
83
|
+
? path.resolve(options.output)
|
|
84
|
+
: resolved.replace(/\.tsx?$/, ".bundle.js");
|
|
85
|
+
fs.writeFileSync(outputPath, bundled, "utf-8");
|
|
86
|
+
const sourceKB = (Buffer.byteLength(source, "utf-8") / 1024).toFixed(1);
|
|
87
|
+
const bundleKB = (Buffer.byteLength(bundled, "utf-8") / 1024).toFixed(1);
|
|
88
|
+
console.log(chalk_1.default.green(`\n ✓ Bundle written to ${path.relative(process.cwd(), outputPath)}`));
|
|
89
|
+
console.log(chalk_1.default.dim(` Source: ${sourceKB} KB → Bundle: ${bundleKB} KB`));
|
|
90
|
+
console.log(chalk_1.default.dim(` Bundle ID: ${bundleId}`));
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
console.error(chalk_1.default.red(`\n Bundle failed: ${err.message}`));
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../src/commands/bundle.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,iDAAiD;AACjD,gFAAgF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAehF,8BAyDC;AAtED,uCAAyB;AACzB,2CAA6B;AAC7B,+CAAiC;AACjC,kDAA0B;AAC1B,8CAA+D;AAC/D,wCAAoC;AAQ7B,KAAK,UAAU,SAAS,CAAC,QAAgB,EAAE,OAAsB;IACtE,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAExC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,mBAAmB,QAAQ,EAAE,CAAC,CAAC,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAElD,iBAAiB;IACjB,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAA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AC,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QAE9C,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAE/C,MAAM,QAAQ,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACxE,MAAM,QAAQ,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAEzE,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,2BAA2B,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;QAChG,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,eAAe,QAAQ,iBAAiB,QAAQ,KAAK,CAAC,CAAC,CAAC;QAC9E,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,kBAAkB,QAAQ,EAAE,CAAC,CAAC,CAAC;IACvD,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,sBAAsB,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// =============================================================================
|
|
3
|
+
// submit command — validate, bundle, and upload to Plotpaper platform
|
|
4
|
+
// =============================================================================
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.runSubmit = runSubmit;
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
45
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
46
|
+
const validation_1 = require("../validation");
|
|
47
|
+
const api_1 = require("../utils/api");
|
|
48
|
+
async function runSubmit(filePath, options) {
|
|
49
|
+
const resolved = path.resolve(filePath);
|
|
50
|
+
if (!fs.existsSync(resolved)) {
|
|
51
|
+
console.error(chalk_1.default.red(`File not found: ${resolved}`));
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
if (!options.email) {
|
|
55
|
+
console.error(chalk_1.default.red("\n Email is required."));
|
|
56
|
+
console.error(chalk_1.default.dim(" Use --email <your-email> to specify your registered Plotpaper email."));
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
const source = fs.readFileSync(resolved, "utf-8");
|
|
60
|
+
// Validate
|
|
61
|
+
console.log();
|
|
62
|
+
console.log(chalk_1.default.bold(`Submitting ${path.basename(resolved)}`));
|
|
63
|
+
const validation = (0, validation_1.validateSource)(source, {
|
|
64
|
+
filePath: resolved,
|
|
65
|
+
schemaPath: options.schema,
|
|
66
|
+
});
|
|
67
|
+
if (!validation.valid) {
|
|
68
|
+
console.log(chalk_1.default.red.bold(`\n Validation failed:`));
|
|
69
|
+
for (const err of validation.errors) {
|
|
70
|
+
console.log(chalk_1.default.red(` ✗ ${err}`));
|
|
71
|
+
}
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
// Resolve app name
|
|
75
|
+
const name = options.name || path.basename(resolved, path.extname(resolved));
|
|
76
|
+
const description = options.description || "";
|
|
77
|
+
const appMode = options.mode || "private";
|
|
78
|
+
// Schema and permissions from validation result
|
|
79
|
+
const schema = validation.schema?.schema;
|
|
80
|
+
const permissions = validation.schema?.permissions;
|
|
81
|
+
console.log(chalk_1.default.dim(`\n Email: ${options.email}`));
|
|
82
|
+
console.log(chalk_1.default.dim(` Name: ${name}`));
|
|
83
|
+
console.log(chalk_1.default.dim(` Mode: ${appMode}`));
|
|
84
|
+
if (schema) {
|
|
85
|
+
console.log(chalk_1.default.dim(` Schema: ${schema.entities.length} entities`));
|
|
86
|
+
}
|
|
87
|
+
if (permissions) {
|
|
88
|
+
console.log(chalk_1.default.dim(` Permissions: ${permissions.length} rule(s)`));
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const result = await (0, api_1.submitApp)({
|
|
92
|
+
email: options.email,
|
|
93
|
+
sourceCode: source,
|
|
94
|
+
name,
|
|
95
|
+
description,
|
|
96
|
+
schema,
|
|
97
|
+
permissions,
|
|
98
|
+
appMode,
|
|
99
|
+
});
|
|
100
|
+
console.log(chalk_1.default.green.bold(`\n ✓ App submitted successfully`));
|
|
101
|
+
console.log(chalk_1.default.dim(` App ID: ${result.appId}`));
|
|
102
|
+
if (result.versionId) {
|
|
103
|
+
console.log(chalk_1.default.dim(` Version ID: ${result.versionId}`));
|
|
104
|
+
}
|
|
105
|
+
if (result.creditsCharged) {
|
|
106
|
+
console.log(chalk_1.default.dim(` Credits charged: ${result.creditsCharged}`));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
console.error(chalk_1.default.red(`\n Submit failed: ${err.message}`));
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=submit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submit.js","sourceRoot":"","sources":["../../src/commands/submit.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,sEAAsE;AACtE,gFAAgF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBhF,8BA0EC;AAzFD,uCAAyB;AACzB,2CAA6B;AAC7B,kDAA0B;AAC1B,8CAA+C;AAE/C,sCAAyC;AAUlC,KAAK,UAAU,SAAS,CAAC,QAAgB,EAAE,OAAsB;IACtE,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAExC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7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CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,eAAe,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACtD,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;YACrB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,mBAAmB,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QAChE,CAAC;QACD,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;YAC1B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,wBAAwB,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,sBAAsB,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// =============================================================================
|
|
3
|
+
// validate command — check source code against all rules
|
|
4
|
+
// =============================================================================
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.runValidate = runValidate;
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
45
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
46
|
+
const validation_1 = require("../validation");
|
|
47
|
+
async function runValidate(filePath, options) {
|
|
48
|
+
const resolved = path.resolve(filePath);
|
|
49
|
+
if (!fs.existsSync(resolved)) {
|
|
50
|
+
console.error(chalk_1.default.red(`File not found: ${resolved}`));
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
const source = fs.readFileSync(resolved, "utf-8");
|
|
54
|
+
const result = (0, validation_1.validateSource)(source, {
|
|
55
|
+
filePath: resolved,
|
|
56
|
+
schemaPath: options?.schema,
|
|
57
|
+
});
|
|
58
|
+
console.log();
|
|
59
|
+
console.log(chalk_1.default.bold(`Validating ${path.basename(resolved)}`));
|
|
60
|
+
console.log();
|
|
61
|
+
if (result.errors.length > 0) {
|
|
62
|
+
console.log(chalk_1.default.red.bold(` ${result.errors.length} error(s):`));
|
|
63
|
+
for (const err of result.errors) {
|
|
64
|
+
console.log(chalk_1.default.red(` ✗ ${err}`));
|
|
65
|
+
}
|
|
66
|
+
console.log();
|
|
67
|
+
}
|
|
68
|
+
if (result.warnings.length > 0) {
|
|
69
|
+
console.log(chalk_1.default.yellow.bold(` ${result.warnings.length} warning(s):`));
|
|
70
|
+
for (const warn of result.warnings) {
|
|
71
|
+
console.log(chalk_1.default.yellow(` ⚠ ${warn}`));
|
|
72
|
+
}
|
|
73
|
+
console.log();
|
|
74
|
+
}
|
|
75
|
+
if (result.schema) {
|
|
76
|
+
const s = result.schema;
|
|
77
|
+
const entityCount = s.schema.entities.length;
|
|
78
|
+
const linkCount = s.schema.links?.length ?? 0;
|
|
79
|
+
console.log(chalk_1.default.cyan(` Schema: ${entityCount} entit${entityCount === 1 ? "y" : "ies"}, ${linkCount} link(s)`));
|
|
80
|
+
for (const entity of s.schema.entities) {
|
|
81
|
+
console.log(chalk_1.default.cyan(` • ${entity.name} (${entity.attrs.length} attrs)`));
|
|
82
|
+
}
|
|
83
|
+
if (s.permissions) {
|
|
84
|
+
console.log(chalk_1.default.cyan(` Permissions: ${s.permissions.length} rule(s)`));
|
|
85
|
+
}
|
|
86
|
+
console.log();
|
|
87
|
+
}
|
|
88
|
+
if (result.valid) {
|
|
89
|
+
const sizeKB = (Buffer.byteLength(source, "utf-8") / 1024).toFixed(1);
|
|
90
|
+
console.log(chalk_1.default.green.bold(` ✓ Valid`) + chalk_1.default.dim(` (${sizeKB} KB)`));
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
console.log(chalk_1.default.red.bold(` ✗ Invalid`));
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=validate.js.map
|