@qpqjs/user-script 0.0.0-stage → 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/README.md +9 -2
- package/lib/commonjs/actionProcessor/getUserScriptBuildActionProcessor.d.ts +1 -0
- package/lib/commonjs/actionProcessor/getUserScriptBuildActionProcessor.js +69 -0
- package/lib/commonjs/actionProcessor/getUserScriptBuildActionProcessor.js.map +1 -0
- package/lib/commonjs/actionProcessor/getUserScriptBuildActionProcessors.d.ts +3 -0
- package/lib/commonjs/actionProcessor/getUserScriptBuildActionProcessors.js +20 -0
- package/lib/commonjs/actionProcessor/getUserScriptBuildActionProcessors.js.map +1 -0
- package/lib/commonjs/actionProcessor/getUserScriptBuildFromZipActionProcessor.d.ts +1 -0
- package/lib/commonjs/actionProcessor/getUserScriptBuildFromZipActionProcessor.js +79 -0
- package/lib/commonjs/actionProcessor/getUserScriptBuildFromZipActionProcessor.js.map +1 -0
- package/lib/commonjs/actionProcessor/index.d.ts +4 -0
- package/lib/commonjs/actionProcessor/index.js +21 -0
- package/lib/commonjs/actionProcessor/index.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/BuiltUserScript.d.ts +4 -0
- package/lib/commonjs/actionProcessor/logic/BuiltUserScript.js +3 -0
- package/lib/commonjs/actionProcessor/logic/BuiltUserScript.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/USER_SCRIPT_SOURCE_LIMITS.d.ts +5 -0
- package/lib/commonjs/actionProcessor/logic/USER_SCRIPT_SOURCE_LIMITS.js +9 -0
- package/lib/commonjs/actionProcessor/logic/USER_SCRIPT_SOURCE_LIMITS.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/UserScriptArchiveError.d.ts +10 -0
- package/lib/commonjs/actionProcessor/logic/UserScriptArchiveError.js +22 -0
- package/lib/commonjs/actionProcessor/logic/UserScriptArchiveError.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/UserScriptSourceFile.d.ts +5 -0
- package/lib/commonjs/actionProcessor/logic/UserScriptSourceFile.js +3 -0
- package/lib/commonjs/actionProcessor/logic/UserScriptSourceFile.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/askUserScriptCheckPublishedOutput.d.ts +8 -0
- package/lib/commonjs/actionProcessor/logic/askUserScriptCheckPublishedOutput.js +30 -0
- package/lib/commonjs/actionProcessor/logic/askUserScriptCheckPublishedOutput.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/askUserScriptCollectSource.d.ts +9 -0
- package/lib/commonjs/actionProcessor/logic/askUserScriptCollectSource.js +53 -0
- package/lib/commonjs/actionProcessor/logic/askUserScriptCollectSource.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/askUserScriptPublishOutput.d.ts +3 -0
- package/lib/commonjs/actionProcessor/logic/askUserScriptPublishOutput.js +9 -0
- package/lib/commonjs/actionProcessor/logic/askUserScriptPublishOutput.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/buildUserScriptInTempDir.d.ts +9 -0
- package/lib/commonjs/actionProcessor/logic/buildUserScriptInTempDir.js +41 -0
- package/lib/commonjs/actionProcessor/logic/buildUserScriptInTempDir.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/extractUserScriptZip.d.ts +8 -0
- package/lib/commonjs/actionProcessor/logic/extractUserScriptZip.js +148 -0
- package/lib/commonjs/actionProcessor/logic/extractUserScriptZip.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/getUserScriptBuildErrorType.d.ts +7 -0
- package/lib/commonjs/actionProcessor/logic/getUserScriptBuildErrorType.js +20 -0
- package/lib/commonjs/actionProcessor/logic/getUserScriptBuildErrorType.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/index.d.ts +12 -0
- package/lib/commonjs/actionProcessor/logic/index.js +29 -0
- package/lib/commonjs/actionProcessor/logic/index.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/isSafeProjectPath.d.ts +5 -0
- package/lib/commonjs/actionProcessor/logic/isSafeProjectPath.js +13 -0
- package/lib/commonjs/actionProcessor/logic/isSafeProjectPath.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/materialiseUserScriptSource.d.ts +3 -0
- package/lib/commonjs/actionProcessor/logic/materialiseUserScriptSource.js +23 -0
- package/lib/commonjs/actionProcessor/logic/materialiseUserScriptSource.js.map +1 -0
- package/lib/commonjs/build/USER_SCRIPT_ENTRY_CANDIDATES.d.ts +2 -0
- package/lib/commonjs/build/USER_SCRIPT_ENTRY_CANDIDATES.js +6 -0
- package/lib/commonjs/build/USER_SCRIPT_ENTRY_CANDIDATES.js.map +1 -0
- package/lib/commonjs/build/USER_SCRIPT_OUTPUT_FILENAME.d.ts +2 -0
- package/lib/commonjs/build/USER_SCRIPT_OUTPUT_FILENAME.js +6 -0
- package/lib/commonjs/build/USER_SCRIPT_OUTPUT_FILENAME.js.map +1 -0
- package/lib/commonjs/build/UserScriptBuildError.d.ts +12 -0
- package/lib/commonjs/build/UserScriptBuildError.js +26 -0
- package/lib/commonjs/build/UserScriptBuildError.js.map +1 -0
- package/lib/commonjs/build/UserScriptBuildResult.d.ts +4 -0
- package/lib/commonjs/build/UserScriptBuildResult.js +3 -0
- package/lib/commonjs/build/UserScriptBuildResult.js.map +1 -0
- package/lib/commonjs/build/__fixtures__/basic/src/helpers/formatSum.d.ts +1 -0
- package/lib/commonjs/build/__fixtures__/basic/src/helpers/formatSum.js +6 -0
- package/lib/commonjs/build/__fixtures__/basic/src/helpers/formatSum.js.map +1 -0
- package/lib/commonjs/build/__fixtures__/basic/src/main.d.ts +4 -0
- package/lib/commonjs/build/__fixtures__/basic/src/main.js +17 -0
- package/lib/commonjs/build/__fixtures__/basic/src/main.js.map +1 -0
- package/lib/commonjs/build/__fixtures__/builtin/src/main.d.ts +1 -0
- package/lib/commonjs/build/__fixtures__/builtin/src/main.js +7 -0
- package/lib/commonjs/build/__fixtures__/builtin/src/main.js.map +1 -0
- package/lib/commonjs/build/__fixtures__/noEntry/src/notMain.d.ts +1 -0
- package/lib/commonjs/build/__fixtures__/noEntry/src/notMain.js +6 -0
- package/lib/commonjs/build/__fixtures__/noEntry/src/notMain.js.map +1 -0
- package/lib/commonjs/build/__fixtures__/nonFunction/src/main.d.ts +2 -0
- package/lib/commonjs/build/__fixtures__/nonFunction/src/main.js +7 -0
- package/lib/commonjs/build/__fixtures__/nonFunction/src/main.js.map +1 -0
- package/lib/commonjs/build/assertUserScriptExports.d.ts +6 -0
- package/lib/commonjs/build/assertUserScriptExports.js +20 -0
- package/lib/commonjs/build/assertUserScriptExports.js.map +1 -0
- package/lib/commonjs/build/buildUserScript.d.ts +15 -0
- package/lib/commonjs/build/buildUserScript.js +55 -0
- package/lib/commonjs/build/buildUserScript.js.map +1 -0
- package/lib/commonjs/build/checkUserScriptOutput.d.ts +7 -0
- package/lib/commonjs/build/checkUserScriptOutput.js +17 -0
- package/lib/commonjs/build/checkUserScriptOutput.js.map +1 -0
- package/lib/commonjs/build/createUserScriptExternals.d.ts +11 -0
- package/lib/commonjs/build/createUserScriptExternals.js +34 -0
- package/lib/commonjs/build/createUserScriptExternals.js.map +1 -0
- package/lib/commonjs/build/getUserScriptRspackConfig.d.ts +15 -0
- package/lib/commonjs/build/getUserScriptRspackConfig.js +49 -0
- package/lib/commonjs/build/getUserScriptRspackConfig.js.map +1 -0
- package/lib/commonjs/build/index.d.ts +13 -0
- package/lib/commonjs/build/index.js +30 -0
- package/lib/commonjs/build/index.js.map +1 -0
- package/lib/commonjs/build/loadRspackModule.d.ts +8 -0
- package/lib/commonjs/build/loadRspackModule.js +51 -0
- package/lib/commonjs/build/loadRspackModule.js.map +1 -0
- package/lib/commonjs/build/resolveUserScriptEntry.d.ts +2 -0
- package/lib/commonjs/build/resolveUserScriptEntry.js +20 -0
- package/lib/commonjs/build/resolveUserScriptEntry.js.map +1 -0
- package/lib/commonjs/build/runUserScriptRspack.d.ts +7 -0
- package/lib/commonjs/build/runUserScriptRspack.js +32 -0
- package/lib/commonjs/build/runUserScriptRspack.js.map +1 -0
- package/lib/commonjs/build/userScriptTsRule.d.ts +6 -0
- package/lib/commonjs/build/userScriptTsRule.js +21 -0
- package/lib/commonjs/build/userScriptTsRule.js.map +1 -0
- package/lib/commonjs/config/USER_SCRIPT_BUILDER_LAYER_MODULES.d.ts +5 -0
- package/lib/commonjs/config/USER_SCRIPT_BUILDER_LAYER_MODULES.js +9 -0
- package/lib/commonjs/config/USER_SCRIPT_BUILDER_LAYER_MODULES.js.map +1 -0
- package/lib/commonjs/config/USER_SCRIPT_BUILDER_LAYER_NAME.d.ts +2 -0
- package/lib/commonjs/config/USER_SCRIPT_BUILDER_LAYER_NAME.js +6 -0
- package/lib/commonjs/config/USER_SCRIPT_BUILDER_LAYER_NAME.js.map +1 -0
- package/lib/commonjs/config/defineUserScriptBuilder.d.ts +7 -0
- package/lib/commonjs/config/defineUserScriptBuilder.js +16 -0
- package/lib/commonjs/config/defineUserScriptBuilder.js.map +1 -0
- package/lib/commonjs/config/getUserScriptBuilderApiLayer.d.ts +7 -0
- package/lib/commonjs/config/getUserScriptBuilderApiLayer.js +18 -0
- package/lib/commonjs/config/getUserScriptBuilderApiLayer.js.map +1 -0
- package/lib/commonjs/config/getUserScriptBuilderLayerDir.d.ts +6 -0
- package/lib/commonjs/config/getUserScriptBuilderLayerDir.js +33 -0
- package/lib/commonjs/config/getUserScriptBuilderLayerDir.js.map +1 -0
- package/lib/commonjs/config/index.d.ts +5 -0
- package/lib/commonjs/config/index.js +22 -0
- package/lib/commonjs/config/index.js.map +1 -0
- package/lib/commonjs/index.d.ts +3 -0
- package/lib/commonjs/index.js +20 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/esm/actionProcessor/getUserScriptBuildActionProcessor.d.ts +1 -0
- package/lib/esm/actionProcessor/getUserScriptBuildActionProcessor.js +56 -0
- package/lib/esm/actionProcessor/getUserScriptBuildActionProcessor.js.map +1 -0
- package/lib/esm/actionProcessor/getUserScriptBuildActionProcessors.d.ts +3 -0
- package/lib/esm/actionProcessor/getUserScriptBuildActionProcessors.js +8 -0
- package/lib/esm/actionProcessor/getUserScriptBuildActionProcessors.js.map +1 -0
- package/lib/esm/actionProcessor/getUserScriptBuildFromZipActionProcessor.d.ts +1 -0
- package/lib/esm/actionProcessor/getUserScriptBuildFromZipActionProcessor.js +66 -0
- package/lib/esm/actionProcessor/getUserScriptBuildFromZipActionProcessor.js.map +1 -0
- package/lib/esm/actionProcessor/index.d.ts +4 -0
- package/lib/esm/actionProcessor/index.js +5 -0
- package/lib/esm/actionProcessor/index.js.map +1 -0
- package/lib/esm/actionProcessor/logic/BuiltUserScript.d.ts +4 -0
- package/lib/esm/actionProcessor/logic/BuiltUserScript.js +2 -0
- package/lib/esm/actionProcessor/logic/BuiltUserScript.js.map +1 -0
- package/lib/esm/actionProcessor/logic/USER_SCRIPT_SOURCE_LIMITS.d.ts +5 -0
- package/lib/esm/actionProcessor/logic/USER_SCRIPT_SOURCE_LIMITS.js +6 -0
- package/lib/esm/actionProcessor/logic/USER_SCRIPT_SOURCE_LIMITS.js.map +1 -0
- package/lib/esm/actionProcessor/logic/UserScriptArchiveError.d.ts +10 -0
- package/lib/esm/actionProcessor/logic/UserScriptArchiveError.js +19 -0
- package/lib/esm/actionProcessor/logic/UserScriptArchiveError.js.map +1 -0
- package/lib/esm/actionProcessor/logic/UserScriptSourceFile.d.ts +5 -0
- package/lib/esm/actionProcessor/logic/UserScriptSourceFile.js +2 -0
- package/lib/esm/actionProcessor/logic/UserScriptSourceFile.js.map +1 -0
- package/lib/esm/actionProcessor/logic/askUserScriptCheckPublishedOutput.d.ts +8 -0
- package/lib/esm/actionProcessor/logic/askUserScriptCheckPublishedOutput.js +27 -0
- package/lib/esm/actionProcessor/logic/askUserScriptCheckPublishedOutput.js.map +1 -0
- package/lib/esm/actionProcessor/logic/askUserScriptCollectSource.d.ts +9 -0
- package/lib/esm/actionProcessor/logic/askUserScriptCollectSource.js +50 -0
- package/lib/esm/actionProcessor/logic/askUserScriptCollectSource.js.map +1 -0
- package/lib/esm/actionProcessor/logic/askUserScriptPublishOutput.d.ts +3 -0
- package/lib/esm/actionProcessor/logic/askUserScriptPublishOutput.js +6 -0
- package/lib/esm/actionProcessor/logic/askUserScriptPublishOutput.js.map +1 -0
- package/lib/esm/actionProcessor/logic/buildUserScriptInTempDir.d.ts +9 -0
- package/lib/esm/actionProcessor/logic/buildUserScriptInTempDir.js +25 -0
- package/lib/esm/actionProcessor/logic/buildUserScriptInTempDir.js.map +1 -0
- package/lib/esm/actionProcessor/logic/extractUserScriptZip.d.ts +8 -0
- package/lib/esm/actionProcessor/logic/extractUserScriptZip.js +132 -0
- package/lib/esm/actionProcessor/logic/extractUserScriptZip.js.map +1 -0
- package/lib/esm/actionProcessor/logic/getUserScriptBuildErrorType.d.ts +7 -0
- package/lib/esm/actionProcessor/logic/getUserScriptBuildErrorType.js +16 -0
- package/lib/esm/actionProcessor/logic/getUserScriptBuildErrorType.js.map +1 -0
- package/lib/esm/actionProcessor/logic/index.d.ts +12 -0
- package/lib/esm/actionProcessor/logic/index.js +13 -0
- package/lib/esm/actionProcessor/logic/index.js.map +1 -0
- package/lib/esm/actionProcessor/logic/isSafeProjectPath.d.ts +5 -0
- package/lib/esm/actionProcessor/logic/isSafeProjectPath.js +9 -0
- package/lib/esm/actionProcessor/logic/isSafeProjectPath.js.map +1 -0
- package/lib/esm/actionProcessor/logic/materialiseUserScriptSource.d.ts +3 -0
- package/lib/esm/actionProcessor/logic/materialiseUserScriptSource.js +16 -0
- package/lib/esm/actionProcessor/logic/materialiseUserScriptSource.js.map +1 -0
- package/lib/esm/build/USER_SCRIPT_ENTRY_CANDIDATES.d.ts +2 -0
- package/lib/esm/build/USER_SCRIPT_ENTRY_CANDIDATES.js +3 -0
- package/lib/esm/build/USER_SCRIPT_ENTRY_CANDIDATES.js.map +1 -0
- package/lib/esm/build/USER_SCRIPT_OUTPUT_FILENAME.d.ts +2 -0
- package/lib/esm/build/USER_SCRIPT_OUTPUT_FILENAME.js +3 -0
- package/lib/esm/build/USER_SCRIPT_OUTPUT_FILENAME.js.map +1 -0
- package/lib/esm/build/UserScriptBuildError.d.ts +12 -0
- package/lib/esm/build/UserScriptBuildError.js +23 -0
- package/lib/esm/build/UserScriptBuildError.js.map +1 -0
- package/lib/esm/build/UserScriptBuildResult.d.ts +4 -0
- package/lib/esm/build/UserScriptBuildResult.js +2 -0
- package/lib/esm/build/UserScriptBuildResult.js.map +1 -0
- package/lib/esm/build/__fixtures__/basic/src/helpers/formatSum.d.ts +1 -0
- package/lib/esm/build/__fixtures__/basic/src/helpers/formatSum.js +2 -0
- package/lib/esm/build/__fixtures__/basic/src/helpers/formatSum.js.map +1 -0
- package/lib/esm/build/__fixtures__/basic/src/main.d.ts +4 -0
- package/lib/esm/build/__fixtures__/basic/src/main.js +11 -0
- package/lib/esm/build/__fixtures__/basic/src/main.js.map +1 -0
- package/lib/esm/build/__fixtures__/builtin/src/main.d.ts +1 -0
- package/lib/esm/build/__fixtures__/builtin/src/main.js +3 -0
- package/lib/esm/build/__fixtures__/builtin/src/main.js.map +1 -0
- package/lib/esm/build/__fixtures__/noEntry/src/notMain.d.ts +1 -0
- package/lib/esm/build/__fixtures__/noEntry/src/notMain.js +2 -0
- package/lib/esm/build/__fixtures__/noEntry/src/notMain.js.map +1 -0
- package/lib/esm/build/__fixtures__/nonFunction/src/main.d.ts +2 -0
- package/lib/esm/build/__fixtures__/nonFunction/src/main.js +3 -0
- package/lib/esm/build/__fixtures__/nonFunction/src/main.js.map +1 -0
- package/lib/esm/build/assertUserScriptExports.d.ts +6 -0
- package/lib/esm/build/assertUserScriptExports.js +16 -0
- package/lib/esm/build/assertUserScriptExports.js.map +1 -0
- package/lib/esm/build/buildUserScript.d.ts +15 -0
- package/lib/esm/build/buildUserScript.js +39 -0
- package/lib/esm/build/buildUserScript.js.map +1 -0
- package/lib/esm/build/checkUserScriptOutput.d.ts +7 -0
- package/lib/esm/build/checkUserScriptOutput.js +10 -0
- package/lib/esm/build/checkUserScriptOutput.js.map +1 -0
- package/lib/esm/build/createUserScriptExternals.d.ts +11 -0
- package/lib/esm/build/createUserScriptExternals.js +30 -0
- package/lib/esm/build/createUserScriptExternals.js.map +1 -0
- package/lib/esm/build/getUserScriptRspackConfig.d.ts +15 -0
- package/lib/esm/build/getUserScriptRspackConfig.js +42 -0
- package/lib/esm/build/getUserScriptRspackConfig.js.map +1 -0
- package/lib/esm/build/index.d.ts +13 -0
- package/lib/esm/build/index.js +14 -0
- package/lib/esm/build/index.js.map +1 -0
- package/lib/esm/build/loadRspackModule.d.ts +8 -0
- package/lib/esm/build/loadRspackModule.js +38 -0
- package/lib/esm/build/loadRspackModule.js.map +1 -0
- package/lib/esm/build/resolveUserScriptEntry.d.ts +2 -0
- package/lib/esm/build/resolveUserScriptEntry.js +13 -0
- package/lib/esm/build/resolveUserScriptEntry.js.map +1 -0
- package/lib/esm/build/runUserScriptRspack.d.ts +7 -0
- package/lib/esm/build/runUserScriptRspack.js +19 -0
- package/lib/esm/build/runUserScriptRspack.js.map +1 -0
- package/lib/esm/build/userScriptTsRule.d.ts +6 -0
- package/lib/esm/build/userScriptTsRule.js +17 -0
- package/lib/esm/build/userScriptTsRule.js.map +1 -0
- package/lib/esm/config/USER_SCRIPT_BUILDER_LAYER_MODULES.d.ts +5 -0
- package/lib/esm/config/USER_SCRIPT_BUILDER_LAYER_MODULES.js +6 -0
- package/lib/esm/config/USER_SCRIPT_BUILDER_LAYER_MODULES.js.map +1 -0
- package/lib/esm/config/USER_SCRIPT_BUILDER_LAYER_NAME.d.ts +2 -0
- package/lib/esm/config/USER_SCRIPT_BUILDER_LAYER_NAME.js +3 -0
- package/lib/esm/config/USER_SCRIPT_BUILDER_LAYER_NAME.js.map +1 -0
- package/lib/esm/config/defineUserScriptBuilder.d.ts +7 -0
- package/lib/esm/config/defineUserScriptBuilder.js +12 -0
- package/lib/esm/config/defineUserScriptBuilder.js.map +1 -0
- package/lib/esm/config/getUserScriptBuilderApiLayer.d.ts +7 -0
- package/lib/esm/config/getUserScriptBuilderApiLayer.js +14 -0
- package/lib/esm/config/getUserScriptBuilderApiLayer.js.map +1 -0
- package/lib/esm/config/getUserScriptBuilderLayerDir.d.ts +6 -0
- package/lib/esm/config/getUserScriptBuilderLayerDir.js +26 -0
- package/lib/esm/config/getUserScriptBuilderLayerDir.js.map +1 -0
- package/lib/esm/config/index.d.ts +5 -0
- package/lib/esm/config/index.js +6 -0
- package/lib/esm/config/index.js.map +1 -0
- package/lib/esm/index.d.ts +3 -0
- package/lib/esm/index.js +4 -0
- package/lib/esm/index.js.map +1 -0
- package/package.json +49 -3
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getUserScriptBuilderLayerDir = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const USER_SCRIPT_BUILDER_LAYER_NAME_1 = require("./USER_SCRIPT_BUILDER_LAYER_NAME");
|
|
10
|
+
const PACKAGE_NAME = '@qpqjs/user-script';
|
|
11
|
+
// This package's root, from src under ts-node or from lib/commonjs, by walking up to its
|
|
12
|
+
// own package.json.
|
|
13
|
+
const getOwnPackageRoot = () => {
|
|
14
|
+
let dir = __dirname;
|
|
15
|
+
while (true) {
|
|
16
|
+
const candidate = path_1.default.join(dir, 'package.json');
|
|
17
|
+
if (fs_1.default.existsSync(candidate) && JSON.parse(fs_1.default.readFileSync(candidate, 'utf8')).name === PACKAGE_NAME) {
|
|
18
|
+
return dir;
|
|
19
|
+
}
|
|
20
|
+
const parent = path_1.default.dirname(dir);
|
|
21
|
+
if (parent === dir)
|
|
22
|
+
throw new Error(`Could not locate the ${PACKAGE_NAME} package root from [${__dirname}]`);
|
|
23
|
+
dir = parent;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The one directory the builder layer lives in: `<this package>/layer`. The api layer
|
|
28
|
+
* entry reads it and `qpq script:builder-layer` writes it, so neither side is told a
|
|
29
|
+
* path. Absolute, which is why the CDK resolves layer paths rather than joining them.
|
|
30
|
+
*/
|
|
31
|
+
const getUserScriptBuilderLayerDir = () => path_1.default.join(getOwnPackageRoot(), 'layer', USER_SCRIPT_BUILDER_LAYER_NAME_1.USER_SCRIPT_BUILDER_LAYER_NAME);
|
|
32
|
+
exports.getUserScriptBuilderLayerDir = getUserScriptBuilderLayerDir;
|
|
33
|
+
//# sourceMappingURL=getUserScriptBuilderLayerDir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUserScriptBuilderLayerDir.js","sourceRoot":"","sources":["../../../src/config/getUserScriptBuilderLayerDir.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB,qFAAkF;AAElF,MAAM,YAAY,GAAG,oBAAoB,CAAC;AAE1C,yFAAyF;AACzF,oBAAoB;AACpB,MAAM,iBAAiB,GAAG,GAAW,EAAE;IACrC,IAAI,GAAG,GAAG,SAAS,CAAC;IACpB,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QACjD,IAAI,YAAE,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YACrG,OAAO,GAAG,CAAC;QACb,CAAC;QACD,MAAM,MAAM,GAAG,cAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,MAAM,KAAK,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,YAAY,uBAAuB,SAAS,GAAG,CAAC,CAAC;QAC7G,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAEF;;;;GAIG;AACI,MAAM,4BAA4B,GAAG,GAAW,EAAE,CAAC,cAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,OAAO,EAAE,+DAA8B,CAAC,CAAC;AAArH,QAAA,4BAA4B,gCAAyF","sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { USER_SCRIPT_BUILDER_LAYER_NAME } from './USER_SCRIPT_BUILDER_LAYER_NAME';\n\nconst PACKAGE_NAME = '@qpqjs/user-script';\n\n// This package's root, from src under ts-node or from lib/commonjs, by walking up to its\n// own package.json.\nconst getOwnPackageRoot = (): string => {\n let dir = __dirname;\n while (true) {\n const candidate = path.join(dir, 'package.json');\n if (fs.existsSync(candidate) && JSON.parse(fs.readFileSync(candidate, 'utf8')).name === PACKAGE_NAME) {\n return dir;\n }\n const parent = path.dirname(dir);\n if (parent === dir) throw new Error(`Could not locate the ${PACKAGE_NAME} package root from [${__dirname}]`);\n dir = parent;\n }\n};\n\n/**\n * The one directory the builder layer lives in: `<this package>/layer`. The api layer\n * entry reads it and `qpq script:builder-layer` writes it, so neither side is told a\n * path. Absolute, which is why the CDK resolves layer paths rather than joining them.\n */\nexport const getUserScriptBuilderLayerDir = (): string => path.join(getOwnPackageRoot(), 'layer', USER_SCRIPT_BUILDER_LAYER_NAME);\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./defineUserScriptBuilder"), exports);
|
|
18
|
+
__exportStar(require("./getUserScriptBuilderApiLayer"), exports);
|
|
19
|
+
__exportStar(require("./getUserScriptBuilderLayerDir"), exports);
|
|
20
|
+
__exportStar(require("./USER_SCRIPT_BUILDER_LAYER_MODULES"), exports);
|
|
21
|
+
__exportStar(require("./USER_SCRIPT_BUILDER_LAYER_NAME"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,iEAA+C;AAC/C,iEAA+C;AAC/C,sEAAoD;AACpD,mEAAiD","sourcesContent":["export * from './defineUserScriptBuilder';\nexport * from './getUserScriptBuilderApiLayer';\nexport * from './getUserScriptBuilderLayerDir';\nexport * from './USER_SCRIPT_BUILDER_LAYER_MODULES';\nexport * from './USER_SCRIPT_BUILDER_LAYER_NAME';\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./actionProcessor"), exports);
|
|
18
|
+
__exportStar(require("./build"), exports);
|
|
19
|
+
__exportStar(require("./config"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,0CAAwB;AACxB,2CAAyB","sourcesContent":["export * from './actionProcessor';\nexport * from './build';\nexport * from './config';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getUserScriptBuildActionProcessor: import("@qpqjs/core").ActionProcessorListResolver;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { loadUserScriptHostModules } from '@qpqjs/actionprocessor-node';
|
|
2
|
+
import { actionResult, actionResultError, askFileListDirectory, askFileReadTextContents, askUserScriptBuild, createActionProcessor, createNestedRuntime, QpqRuntimeType, } from '@qpqjs/core';
|
|
3
|
+
import { randomUUID } from 'crypto';
|
|
4
|
+
import { UserScriptBuildError } from '../build/UserScriptBuildError';
|
|
5
|
+
import { askUserScriptCheckPublishedOutput } from './logic/askUserScriptCheckPublishedOutput';
|
|
6
|
+
import { askUserScriptCollectSource } from './logic/askUserScriptCollectSource';
|
|
7
|
+
import { askUserScriptPublishOutput } from './logic/askUserScriptPublishOutput';
|
|
8
|
+
import { buildUserScriptInTempDir } from './logic/buildUserScriptInTempDir';
|
|
9
|
+
import { getUserScriptBuildErrorType } from './logic/getUserScriptBuildErrorType';
|
|
10
|
+
import { materialiseUserScriptSource } from './logic/materialiseUserScriptSource';
|
|
11
|
+
const { errorType } = askUserScriptBuild;
|
|
12
|
+
const getDateNow = () => new Date().toISOString();
|
|
13
|
+
// Drive failures while collecting the source, re-labelled into this action's catalog; any
|
|
14
|
+
// other failure passes through with its own type.
|
|
15
|
+
const COLLECT_ERROR_TYPES = {
|
|
16
|
+
[askFileListDirectory.errorType.DirectoryNotFound]: errorType.SourceNotFound,
|
|
17
|
+
[askFileListDirectory.errorType.DriveNotFound]: errorType.DriveNotFound,
|
|
18
|
+
[askFileListDirectory.errorType.InvalidScope]: errorType.InvalidScope,
|
|
19
|
+
[askFileReadTextContents.errorType.InvalidScope]: errorType.InvalidScope,
|
|
20
|
+
};
|
|
21
|
+
const getProcessBuild = (qpqConfig) => {
|
|
22
|
+
return async (payload, session, actionProcessors, logger, updateSession, dynamicModuleLoader, streamRegistry) => {
|
|
23
|
+
const resolveStory = createNestedRuntime(qpqConfig, session, actionProcessors, getDateNow, logger, randomUUID, QpqRuntimeType.EXECUTE_STORY, dynamicModuleLoader, undefined, [], streamRegistry);
|
|
24
|
+
// The source and the output both travel through the file actions, so each runtime's
|
|
25
|
+
// own drive implementation serves them; only the build itself touches local disk.
|
|
26
|
+
const collected = await resolveStory(() => askUserScriptCollectSource(payload.drive, payload.sourceDirectory, payload.scope), []);
|
|
27
|
+
if (collected.error) {
|
|
28
|
+
return actionResultError(COLLECT_ERROR_TYPES[collected.error.errorType] ?? collected.error.errorType, collected.error.errorText);
|
|
29
|
+
}
|
|
30
|
+
// The service's own script modules, which the bundler keeps external. One that does not
|
|
31
|
+
// load is the service's fault, so it throws rather than failing the build.
|
|
32
|
+
const hostModules = await loadUserScriptHostModules(qpqConfig, dynamicModuleLoader);
|
|
33
|
+
let built;
|
|
34
|
+
try {
|
|
35
|
+
built = await buildUserScriptInTempDir((projectDir) => materialiseUserScriptSource(projectDir, collected.result), payload.sourceMap, hostModules);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error instanceof UserScriptBuildError) {
|
|
39
|
+
return actionResultError(getUserScriptBuildErrorType(error.code, errorType), error.message);
|
|
40
|
+
}
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
const published = await resolveStory(() => askUserScriptPublishOutput(payload.drive, payload.outputFilepath, built.script, payload.scope), []);
|
|
44
|
+
if (published.error) {
|
|
45
|
+
return actionResultError(published.error.errorType, published.error.errorText);
|
|
46
|
+
}
|
|
47
|
+
// The output contract is judged where the script's top-level code cannot reach the host.
|
|
48
|
+
const checked = await resolveStory(() => askUserScriptCheckPublishedOutput(payload.drive, payload.outputFilepath, payload.scope, errorType), []);
|
|
49
|
+
if (checked.error) {
|
|
50
|
+
return actionResultError(checked.error.errorType, checked.error.errorText);
|
|
51
|
+
}
|
|
52
|
+
return actionResult({ exports: checked.result });
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export const getUserScriptBuildActionProcessor = createActionProcessor(askUserScriptBuild, getProcessBuild);
|
|
56
|
+
//# sourceMappingURL=getUserScriptBuildActionProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUserScriptBuildActionProcessor.js","sourceRoot":"","sources":["../../../src/actionProcessor/getUserScriptBuildActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAEL,YAAY,EACZ,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EAKnB,cAAc,GAKf,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,iCAAiC,EAAE,MAAM,2CAA2C,CAAC;AAC9F,OAAO,EAAE,0BAA0B,EAAE,MA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GAAG,MAAM,YAAY,CAAC,GAAG,EAAE,CAAC,iCAAiC,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;QACjJ,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAClB,OAAO,iBAAiB,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC7E,CAAC;QAED,OAAO,YAAY,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACnD,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iCAAiC,GAAG,qBAAqB,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC","sourcesContent":["import { loadUserScriptHostModules } from '@qpqjs/actionprocessor-node';\nimport {\n ActionProcessorList,\n actionResult,\n actionResultError,\n askFileListDirectory,\n askFileReadTextContents,\n askUserScriptBuild,\n createActionProcessor,\n createNestedRuntime,\n DynamicModuleLoader,\n ProcessorFor,\n QPQConfig,\n QpqLogger,\n QpqRuntimeType,\n StorySession,\n StorySessionUpdater,\n StreamRegistry,\n UserScriptBuildActionPayload,\n} from '@qpqjs/core';\n\nimport { randomUUID } from 'crypto';\n\nimport { UserScriptBuildError } from '../build/UserScriptBuildError';\nimport { askUserScriptCheckPublishedOutput } from './logic/askUserScriptCheckPublishedOutput';\nimport { askUserScriptCollectSource } from './logic/askUserScriptCollectSource';\nimport { askUserScriptPublishOutput } from './logic/askUserScriptPublishOutput';\nimport { buildUserScriptInTempDir } from './logic/buildUserScriptInTempDir';\nimport { BuiltUserScript } from './logic/BuiltUserScript';\nimport { getUserScriptBuildErrorType } from './logic/getUserScriptBuildErrorType';\nimport { materialiseUserScriptSource } from './logic/materialiseUserScriptSource';\n\nconst { errorType } = askUserScriptBuild;\n\nconst getDateNow = () => new Date().toISOString();\n\n// Drive failures while collecting the source, re-labelled into this action's catalog; any\n// other failure passes through with its own type.\nconst COLLECT_ERROR_TYPES: Record<string, string> = {\n [askFileListDirectory.errorType.DirectoryNotFound]: errorType.SourceNotFound,\n [askFileListDirectory.errorType.DriveNotFound]: errorType.DriveNotFound,\n [askFileListDirectory.errorType.InvalidScope]: errorType.InvalidScope,\n [askFileReadTextContents.errorType.InvalidScope]: errorType.InvalidScope,\n};\n\nconst getProcessBuild = (qpqConfig: QPQConfig): ProcessorFor<typeof askUserScriptBuild> => {\n return async (\n payload: UserScriptBuildActionPayload,\n session: StorySession,\n actionProcessors: ActionProcessorList,\n logger: QpqLogger,\n updateSession: StorySessionUpdater,\n dynamicModuleLoader: DynamicModuleLoader,\n streamRegistry: StreamRegistry,\n ) => {\n const resolveStory = createNestedRuntime(\n qpqConfig,\n session,\n actionProcessors,\n getDateNow,\n logger,\n randomUUID,\n QpqRuntimeType.EXECUTE_STORY,\n dynamicModuleLoader,\n undefined,\n [],\n streamRegistry,\n );\n\n // The source and the output both travel through the file actions, so each runtime's\n // own drive implementation serves them; only the build itself touches local disk.\n const collected = await resolveStory(() => askUserScriptCollectSource(payload.drive, payload.sourceDirectory, payload.scope), []);\n if (collected.error) {\n return actionResultError(COLLECT_ERROR_TYPES[collected.error.errorType] ?? collected.error.errorType, collected.error.errorText);\n }\n\n // The service's own script modules, which the bundler keeps external. One that does not\n // load is the service's fault, so it throws rather than failing the build.\n const hostModules = await loadUserScriptHostModules(qpqConfig, dynamicModuleLoader);\n\n let built: BuiltUserScript;\n try {\n built = await buildUserScriptInTempDir(\n (projectDir) => materialiseUserScriptSource(projectDir, collected.result),\n payload.sourceMap,\n hostModules,\n );\n } catch (error) {\n if (error instanceof UserScriptBuildError) {\n return actionResultError(getUserScriptBuildErrorType(error.code, errorType), error.message);\n }\n throw error;\n }\n\n const published = await resolveStory(() => askUserScriptPublishOutput(payload.drive, payload.outputFilepath, built.script, payload.scope), []);\n if (published.error) {\n return actionResultError(published.error.errorType, published.error.errorText);\n }\n\n // The output contract is judged where the script's top-level code cannot reach the host.\n const checked = await resolveStory(() => askUserScriptCheckPublishedOutput(payload.drive, payload.outputFilepath, payload.scope, errorType), []);\n if (checked.error) {\n return actionResultError(checked.error.errorType, checked.error.errorText);\n }\n\n return actionResult({ exports: checked.result });\n };\n};\n\nexport const getUserScriptBuildActionProcessor = createActionProcessor(askUserScriptBuild, getProcessBuild);\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getUserScriptBuildActionProcessor } from './getUserScriptBuildActionProcessor';
|
|
2
|
+
import { getUserScriptBuildFromZipActionProcessor } from './getUserScriptBuildFromZipActionProcessor';
|
|
3
|
+
/** The resolver defineUserScriptBuilder points a service at: both build actions, from a directory and from a zip. */
|
|
4
|
+
export const getUserScriptBuildActionProcessors = async (qpqConfig, dynamicModuleLoader) => ({
|
|
5
|
+
...(await getUserScriptBuildActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
6
|
+
...(await getUserScriptBuildFromZipActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
7
|
+
});
|
|
8
|
+
//# sourceMappingURL=getUserScriptBuildActionProcessors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUserScriptBuildActionProcessors.js","sourceRoot":"","sources":["../../../src/actionProcessor/getUserScriptBuildActionProcessors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,wCAAwC,EAAE,MAAM,4CAA4C,CAAC;AAEtG,qHAAqH;AACrH,MAAM,CAAC,MAAM,kCAAkC,GAAgC,KAAK,EAClF,SAAoB,EACpB,mBAAwC,EACV,EAAE,CAAC,CAAC;IAClC,GAAG,CAAC,MAAM,iCAAiC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IAC5E,GAAG,CAAC,MAAM,wCAAwC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;CACpF,CAAC,CAAC","sourcesContent":["import { ActionProcessorList, ActionProcessorListResolver, DynamicModuleLoader, QPQConfig } from '@qpqjs/core';\n\nimport { getUserScriptBuildActionProcessor } from './getUserScriptBuildActionProcessor';\nimport { getUserScriptBuildFromZipActionProcessor } from './getUserScriptBuildFromZipActionProcessor';\n\n/** The resolver defineUserScriptBuilder points a service at: both build actions, from a directory and from a zip. */\nexport const getUserScriptBuildActionProcessors: ActionProcessorListResolver = async (\n qpqConfig: QPQConfig,\n dynamicModuleLoader: DynamicModuleLoader,\n): Promise<ActionProcessorList> => ({\n ...(await getUserScriptBuildActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserScriptBuildFromZipActionProcessor(qpqConfig, dynamicModuleLoader)),\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getUserScriptBuildFromZipActionProcessor: import("@qpqjs/core").ActionProcessorListResolver;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { loadUserScriptHostModules } from '@qpqjs/actionprocessor-node';
|
|
2
|
+
import { actionResult, actionResultError, askFileReadBinaryContents, askUserScriptBuildFromZip, createActionProcessor, createNestedRuntime, QpqRuntimeType, } from '@qpqjs/core';
|
|
3
|
+
import { randomUUID } from 'crypto';
|
|
4
|
+
import { UserScriptBuildError } from '../build/UserScriptBuildError';
|
|
5
|
+
import { askUserScriptCheckPublishedOutput } from './logic/askUserScriptCheckPublishedOutput';
|
|
6
|
+
import { askUserScriptPublishOutput } from './logic/askUserScriptPublishOutput';
|
|
7
|
+
import { buildUserScriptInTempDir } from './logic/buildUserScriptInTempDir';
|
|
8
|
+
import { extractUserScriptZip } from './logic/extractUserScriptZip';
|
|
9
|
+
import { getUserScriptBuildErrorType } from './logic/getUserScriptBuildErrorType';
|
|
10
|
+
import { USER_SCRIPT_SOURCE_LIMITS } from './logic/USER_SCRIPT_SOURCE_LIMITS';
|
|
11
|
+
import { UserScriptArchiveError } from './logic/UserScriptArchiveError';
|
|
12
|
+
const { errorType } = askUserScriptBuildFromZip;
|
|
13
|
+
const getDateNow = () => new Date().toISOString();
|
|
14
|
+
// Drive failures while reading the zip, re-labelled into this action's catalog; any other
|
|
15
|
+
// failure passes through with its own type.
|
|
16
|
+
const READ_ERROR_TYPES = {
|
|
17
|
+
[askFileReadBinaryContents.errorType.FileNotFound]: errorType.SourceNotFound,
|
|
18
|
+
[askFileReadBinaryContents.errorType.InvalidScope]: errorType.InvalidScope,
|
|
19
|
+
};
|
|
20
|
+
// The archive error codes are named after the action's own catalog.
|
|
21
|
+
const getArchiveErrorType = (error) => errorType[error.code];
|
|
22
|
+
const getProcessBuildFromZip = (qpqConfig) => {
|
|
23
|
+
return async (payload, session, actionProcessors, logger, updateSession, dynamicModuleLoader, streamRegistry) => {
|
|
24
|
+
const resolveStory = createNestedRuntime(qpqConfig, session, actionProcessors, getDateNow, logger, randomUUID, QpqRuntimeType.EXECUTE_STORY, dynamicModuleLoader, undefined, [], streamRegistry);
|
|
25
|
+
const read = await resolveStory(() => askFileReadBinaryContents(payload.drive, payload.zipFilepath, payload.scope), []);
|
|
26
|
+
if (read.error) {
|
|
27
|
+
return actionResultError(READ_ERROR_TYPES[read.error.errorType] ?? read.error.errorType, read.error.errorText);
|
|
28
|
+
}
|
|
29
|
+
// The file actions give no size without the bytes, so the zip's own cap applies to
|
|
30
|
+
// what came back before anything is unpacked.
|
|
31
|
+
const zip = Buffer.from(read.result.base64Data, 'base64');
|
|
32
|
+
if (zip.length > USER_SCRIPT_SOURCE_LIMITS.maxBytes) {
|
|
33
|
+
return actionResultError(errorType.SourceTooLarge, `[${payload.drive}:${payload.zipFilepath}] is larger than ${USER_SCRIPT_SOURCE_LIMITS.maxBytes} bytes`);
|
|
34
|
+
}
|
|
35
|
+
// The service's own script modules, which the bundler keeps external. One that does not
|
|
36
|
+
// load is the service's fault, so it throws rather than failing the build.
|
|
37
|
+
const hostModules = await loadUserScriptHostModules(qpqConfig, dynamicModuleLoader);
|
|
38
|
+
let built;
|
|
39
|
+
try {
|
|
40
|
+
built = await buildUserScriptInTempDir(async (projectDir) => {
|
|
41
|
+
await extractUserScriptZip(zip, projectDir);
|
|
42
|
+
}, payload.sourceMap, hostModules);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
if (error instanceof UserScriptArchiveError) {
|
|
46
|
+
return actionResultError(getArchiveErrorType(error), `[${payload.drive}:${payload.zipFilepath}] ${error.message}`);
|
|
47
|
+
}
|
|
48
|
+
if (error instanceof UserScriptBuildError) {
|
|
49
|
+
return actionResultError(getUserScriptBuildErrorType(error.code, errorType), error.message);
|
|
50
|
+
}
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
const published = await resolveStory(() => askUserScriptPublishOutput(payload.drive, payload.outputFilepath, built.script, payload.scope), []);
|
|
54
|
+
if (published.error) {
|
|
55
|
+
return actionResultError(published.error.errorType, published.error.errorText);
|
|
56
|
+
}
|
|
57
|
+
// The output contract is judged where the script's top-level code cannot reach the host.
|
|
58
|
+
const checked = await resolveStory(() => askUserScriptCheckPublishedOutput(payload.drive, payload.outputFilepath, payload.scope, errorType), []);
|
|
59
|
+
if (checked.error) {
|
|
60
|
+
return actionResultError(checked.error.errorType, checked.error.errorText);
|
|
61
|
+
}
|
|
62
|
+
return actionResult({ exports: checked.result });
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export const getUserScriptBuildFromZipActionProcessor = createActionProcessor(askUserScriptBuildFromZip, getProcessBuildFromZip);
|
|
66
|
+
//# sourceMappingURL=getUserScriptBuildFromZipActionProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUserScriptBuildFromZipActionProcessor.js","sourceRoot":"","sources":["../../../src/actionProcessor/getUserScriptBuildFromZipActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAEL,YAAY,EACZ,iBAAiB,EACjB,yBAAyB,EACzB,yBAAyB,E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,CAAC,CAAC;IACnD,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,wCAAwC,GAAG,qBAAqB,CAAC,yBAAyB,EAAE,sBAAsB,CAAC,CAAC","sourcesContent":["import { loadUserScriptHostModules } from '@qpqjs/actionprocessor-node';\nimport {\n ActionProcessorList,\n actionResult,\n actionResultError,\n askFileReadBinaryContents,\n askUserScriptBuildFromZip,\n createActionProcessor,\n createNestedRuntime,\n DynamicModuleLoader,\n ProcessorFor,\n QPQConfig,\n QpqLogger,\n QpqRuntimeType,\n StorySession,\n StorySessionUpdater,\n StreamRegistry,\n UserScriptBuildFromZipActionPayload,\n} from '@qpqjs/core';\n\nimport { randomUUID } from 'crypto';\n\nimport { UserScriptBuildError } from '../build/UserScriptBuildError';\nimport { askUserScriptCheckPublishedOutput } from './logic/askUserScriptCheckPublishedOutput';\nimport { askUserScriptPublishOutput } from './logic/askUserScriptPublishOutput';\nimport { buildUserScriptInTempDir } from './logic/buildUserScriptInTempDir';\nimport { BuiltUserScript } from './logic/BuiltUserScript';\nimport { extractUserScriptZip } from './logic/extractUserScriptZip';\nimport { getUserScriptBuildErrorType } from './logic/getUserScriptBuildErrorType';\nimport { USER_SCRIPT_SOURCE_LIMITS } from './logic/USER_SCRIPT_SOURCE_LIMITS';\nimport { UserScriptArchiveError } from './logic/UserScriptArchiveError';\n\nconst { errorType } = askUserScriptBuildFromZip;\n\nconst getDateNow = () => new Date().toISOString();\n\n// Drive failures while reading the zip, re-labelled into this action's catalog; any other\n// failure passes through with its own type.\nconst READ_ERROR_TYPES: Record<string, string> = {\n [askFileReadBinaryContents.errorType.FileNotFound]: errorType.SourceNotFound,\n [askFileReadBinaryContents.errorType.InvalidScope]: errorType.InvalidScope,\n};\n\n// The archive error codes are named after the action's own catalog.\nconst getArchiveErrorType = (error: UserScriptArchiveError): string => errorType[error.code];\n\nconst getProcessBuildFromZip = (qpqConfig: QPQConfig): ProcessorFor<typeof askUserScriptBuildFromZip> => {\n return async (\n payload: UserScriptBuildFromZipActionPayload,\n session: StorySession,\n actionProcessors: ActionProcessorList,\n logger: QpqLogger,\n updateSession: StorySessionUpdater,\n dynamicModuleLoader: DynamicModuleLoader,\n streamRegistry: StreamRegistry,\n ) => {\n const resolveStory = createNestedRuntime(\n qpqConfig,\n session,\n actionProcessors,\n getDateNow,\n logger,\n randomUUID,\n QpqRuntimeType.EXECUTE_STORY,\n dynamicModuleLoader,\n undefined,\n [],\n streamRegistry,\n );\n\n const read = await resolveStory(() => askFileReadBinaryContents(payload.drive, payload.zipFilepath, payload.scope), []);\n if (read.error) {\n return actionResultError(READ_ERROR_TYPES[read.error.errorType] ?? read.error.errorType, read.error.errorText);\n }\n\n // The file actions give no size without the bytes, so the zip's own cap applies to\n // what came back before anything is unpacked.\n const zip = Buffer.from(read.result.base64Data, 'base64');\n if (zip.length > USER_SCRIPT_SOURCE_LIMITS.maxBytes) {\n return actionResultError(\n errorType.SourceTooLarge,\n `[${payload.drive}:${payload.zipFilepath}] is larger than ${USER_SCRIPT_SOURCE_LIMITS.maxBytes} bytes`,\n );\n }\n\n // The service's own script modules, which the bundler keeps external. One that does not\n // load is the service's fault, so it throws rather than failing the build.\n const hostModules = await loadUserScriptHostModules(qpqConfig, dynamicModuleLoader);\n\n let built: BuiltUserScript;\n try {\n built = await buildUserScriptInTempDir(\n async (projectDir) => {\n await extractUserScriptZip(zip, projectDir);\n },\n payload.sourceMap,\n hostModules,\n );\n } catch (error) {\n if (error instanceof UserScriptArchiveError) {\n return actionResultError(getArchiveErrorType(error), `[${payload.drive}:${payload.zipFilepath}] ${error.message}`);\n }\n if (error instanceof UserScriptBuildError) {\n return actionResultError(getUserScriptBuildErrorType(error.code, errorType), error.message);\n }\n throw error;\n }\n\n const published = await resolveStory(() => askUserScriptPublishOutput(payload.drive, payload.outputFilepath, built.script, payload.scope), []);\n if (published.error) {\n return actionResultError(published.error.errorType, published.error.errorText);\n }\n\n // The output contract is judged where the script's top-level code cannot reach the host.\n const checked = await resolveStory(() => askUserScriptCheckPublishedOutput(payload.drive, payload.outputFilepath, payload.scope, errorType), []);\n if (checked.error) {\n return actionResultError(checked.error.errorType, checked.error.errorText);\n }\n\n return actionResult({ exports: checked.result });\n };\n};\n\nexport const getUserScriptBuildFromZipActionProcessor = createActionProcessor(askUserScriptBuildFromZip, getProcessBuildFromZip);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/actionProcessor/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,SAAS,CAAC","sourcesContent":["export * from './getUserScriptBuildActionProcessor';\nexport * from './getUserScriptBuildActionProcessors';\nexport * from './getUserScriptBuildFromZipActionProcessor';\nexport * from './logic';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BuiltUserScript.js","sourceRoot":"","sources":["../../../../src/actionProcessor/logic/BuiltUserScript.ts"],"names":[],"mappings":"","sourcesContent":["/** A finished build, read back from disk, ready to publish to a drive. */\nexport type BuiltUserScript = {\n // The built JavaScript, with its source map embedded when one was asked for.\n script: string;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"USER_SCRIPT_SOURCE_LIMITS.js","sourceRoot":"","sources":["../../../../src/actionProcessor/logic/USER_SCRIPT_SOURCE_LIMITS.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI;CACjB,CAAC","sourcesContent":["/** Caps on a script project pulled off a drive, so a build cannot exhaust the lambda it runs on. */\nexport const USER_SCRIPT_SOURCE_LIMITS = {\n maxFiles: 200,\n maxBytes: 2 * 1024 * 1024,\n} as const;\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare enum UserScriptArchiveErrorCode {
|
|
2
|
+
InvalidArchive = "InvalidArchive",
|
|
3
|
+
UnsafeArchiveEntry = "UnsafeArchiveEntry",
|
|
4
|
+
SourceTooLarge = "SourceTooLarge"
|
|
5
|
+
}
|
|
6
|
+
/** Thrown by extractUserScriptZip; `code` names which rule the archive broke. */
|
|
7
|
+
export declare class UserScriptArchiveError extends Error {
|
|
8
|
+
readonly code: UserScriptArchiveErrorCode;
|
|
9
|
+
constructor(code: UserScriptArchiveErrorCode, message: string);
|
|
10
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export var UserScriptArchiveErrorCode;
|
|
2
|
+
(function (UserScriptArchiveErrorCode) {
|
|
3
|
+
// Not a zip this runtime can read, or an entry is encrypted or corrupt.
|
|
4
|
+
UserScriptArchiveErrorCode["InvalidArchive"] = "InvalidArchive";
|
|
5
|
+
// An entry path would escape the project, or an entry is a symlink.
|
|
6
|
+
UserScriptArchiveErrorCode["UnsafeArchiveEntry"] = "UnsafeArchiveEntry";
|
|
7
|
+
// Too many files, too many unpacked bytes, or a node_modules folder.
|
|
8
|
+
UserScriptArchiveErrorCode["SourceTooLarge"] = "SourceTooLarge";
|
|
9
|
+
})(UserScriptArchiveErrorCode || (UserScriptArchiveErrorCode = {}));
|
|
10
|
+
/** Thrown by extractUserScriptZip; `code` names which rule the archive broke. */
|
|
11
|
+
export class UserScriptArchiveError extends Error {
|
|
12
|
+
code;
|
|
13
|
+
constructor(code, message) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.code = code;
|
|
16
|
+
this.name = 'UserScriptArchiveError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=UserScriptArchiveError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserScriptArchiveError.js","sourceRoot":"","sources":["../../../../src/actionProcessor/logic/UserScriptArchiveError.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,0BAOX;AAPD,WAAY,0BAA0B;IACpC,wEAAwE;IACxE,+DAAiC,CAAA;IACjC,oEAAoE;IACpE,uEAAyC,CAAA;IACzC,qEAAqE;IACrE,+DAAiC,CAAA;AACnC,CAAC,EAPW,0BAA0B,KAA1B,0BAA0B,QAOrC;AAED,iFAAiF;AACjF,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAE7B;IADlB,YACkB,IAAgC,EAChD,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAA4B;QAIhD,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF","sourcesContent":["export enum UserScriptArchiveErrorCode {\n // Not a zip this runtime can read, or an entry is encrypted or corrupt.\n InvalidArchive = 'InvalidArchive',\n // An entry path would escape the project, or an entry is a symlink.\n UnsafeArchiveEntry = 'UnsafeArchiveEntry',\n // Too many files, too many unpacked bytes, or a node_modules folder.\n SourceTooLarge = 'SourceTooLarge',\n}\n\n/** Thrown by extractUserScriptZip; `code` names which rule the archive broke. */\nexport class UserScriptArchiveError extends Error {\n constructor(\n public readonly code: UserScriptArchiveErrorCode,\n message: string,\n ) {\n super(message);\n this.name = 'UserScriptArchiveError';\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserScriptSourceFile.js","sourceRoot":"","sources":["../../../../src/actionProcessor/logic/UserScriptSourceFile.ts"],"names":[],"mappings":"","sourcesContent":["/** One file of a script project pulled off a drive: its path relative to the project root, and its text. */\nexport type UserScriptSourceFile = {\n path: string;\n text: string;\n};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AskResponse } from '@qpqjs/core';
|
|
2
|
+
import { UserScriptBuildErrorCatalog } from './getUserScriptBuildErrorType';
|
|
3
|
+
/**
|
|
4
|
+
* The output contract for a platform build, judged inside the sandbox: the runner loads the
|
|
5
|
+
* published file and reports its exports, and the rule is applied here. A load failure is the
|
|
6
|
+
* build's fault (BuildFailed); a runner failure keeps its own type.
|
|
7
|
+
*/
|
|
8
|
+
export declare function askUserScriptCheckPublishedOutput(drive: string, filepath: string, scope: string | undefined, errorType: UserScriptBuildErrorCatalog): AskResponse<string[]>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { askCatch, askThrowError, askUserScriptListExports } from '@qpqjs/core';
|
|
2
|
+
import { assertUserScriptExports } from '../../build/assertUserScriptExports';
|
|
3
|
+
import { UserScriptBuildError } from '../../build/UserScriptBuildError';
|
|
4
|
+
/**
|
|
5
|
+
* The output contract for a platform build, judged inside the sandbox: the runner loads the
|
|
6
|
+
* published file and reports its exports, and the rule is applied here. A load failure is the
|
|
7
|
+
* build's fault (BuildFailed); a runner failure keeps its own type.
|
|
8
|
+
*/
|
|
9
|
+
export function* askUserScriptCheckPublishedOutput(drive, filepath, scope, errorType) {
|
|
10
|
+
const listed = yield* askCatch(askUserScriptListExports(drive, filepath, scope));
|
|
11
|
+
if (!listed.success) {
|
|
12
|
+
const loadFailed = listed.error.errorType === askUserScriptListExports.errorType.ModuleNotFound ||
|
|
13
|
+
listed.error.errorType === askUserScriptListExports.errorType.ScriptInvalid;
|
|
14
|
+
return yield* askThrowError(loadFailed ? errorType.BuildFailed : listed.error.errorType, listed.error.errorText);
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
return assertUserScriptExports(filepath, listed.result);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error instanceof UserScriptBuildError) {
|
|
21
|
+
const code = error.code;
|
|
22
|
+
return yield* askThrowError(errorType[code], error.message);
|
|
23
|
+
}
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=askUserScriptCheckPublishedOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"askUserScriptCheckPublishedOutput.js","sourceRoot":"","sources":["../../../../src/actionProcessor/logic/askUserScriptCheck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AAC","sourcesContent":["import { askCatch, AskResponse, askThrowError, askUserScriptListExports } from '@qpqjs/core';\n\nimport { assertUserScriptExports } from '../../build/assertUserScriptExports';\nimport { UserScriptBuildError, UserScriptBuildErrorCode } from '../../build/UserScriptBuildError';\nimport { UserScriptBuildErrorCatalog } from './getUserScriptBuildErrorType';\n\n/**\n * The output contract for a platform build, judged inside the sandbox: the runner loads the\n * published file and reports its exports, and the rule is applied here. A load failure is the\n * build's fault (BuildFailed); a runner failure keeps its own type.\n */\nexport function* askUserScriptCheckPublishedOutput(\n drive: string,\n filepath: string,\n scope: string | undefined,\n errorType: UserScriptBuildErrorCatalog,\n): AskResponse<string[]> {\n const listed = yield* askCatch(askUserScriptListExports(drive, filepath, scope));\n if (!listed.success) {\n const loadFailed =\n listed.error.errorType === askUserScriptListExports.errorType.ModuleNotFound ||\n listed.error.errorType === askUserScriptListExports.errorType.ScriptInvalid;\n return yield* askThrowError(loadFailed ? errorType.BuildFailed : listed.error.errorType, listed.error.errorText);\n }\n\n try {\n return assertUserScriptExports(filepath, listed.result);\n } catch (error) {\n if (error instanceof UserScriptBuildError) {\n const code = error.code as UserScriptBuildErrorCode.NoExports | UserScriptBuildErrorCode.NonFunctionExport;\n return yield* askThrowError(errorType[code], error.message);\n }\n throw error;\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AskResponse } from '@qpqjs/core';
|
|
2
|
+
import { UserScriptSourceFile } from './UserScriptSourceFile';
|
|
3
|
+
/**
|
|
4
|
+
* Reads a script project off a drive: every file under `sourceDirectory`, recursively, as
|
|
5
|
+
* text with paths relative to the project root. Refuses a node_modules folder and enforces
|
|
6
|
+
* USER_SCRIPT_SOURCE_LIMITS, both as the build action's SourceTooLarge. Listing and read
|
|
7
|
+
* failures propagate with their own types for the processor to re-label.
|
|
8
|
+
*/
|
|
9
|
+
export declare function askUserScriptCollectSource(drive: string, sourceDirectory: string, scope?: string): AskResponse<UserScriptSourceFile[]>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { askFileListAllDirectory, askFileReadTextContents, askThrowError, askUserScriptBuild } from '@qpqjs/core';
|
|
2
|
+
import { USER_SCRIPT_SOURCE_LIMITS } from './USER_SCRIPT_SOURCE_LIMITS';
|
|
3
|
+
const REFUSED_DIRECTORY = 'node_modules';
|
|
4
|
+
const trimSlashes = (directory) => directory.replace(/^\/+|\/+$/g, '');
|
|
5
|
+
const toProjectRelative = (sourceDirectory, filepath) => {
|
|
6
|
+
const prefix = `${sourceDirectory}/`;
|
|
7
|
+
return filepath.startsWith(prefix) ? filepath.slice(prefix.length) : filepath;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Reads a script project off a drive: every file under `sourceDirectory`, recursively, as
|
|
11
|
+
* text with paths relative to the project root. Refuses a node_modules folder and enforces
|
|
12
|
+
* USER_SCRIPT_SOURCE_LIMITS, both as the build action's SourceTooLarge. Listing and read
|
|
13
|
+
* failures propagate with their own types for the processor to re-label.
|
|
14
|
+
*/
|
|
15
|
+
export function* askUserScriptCollectSource(drive, sourceDirectory, scope) {
|
|
16
|
+
const root = trimSlashes(sourceDirectory);
|
|
17
|
+
const pending = [root];
|
|
18
|
+
const filePaths = [];
|
|
19
|
+
while (pending.length > 0) {
|
|
20
|
+
const directory = pending.shift();
|
|
21
|
+
const entries = yield* askFileListAllDirectory(drive, directory, scope);
|
|
22
|
+
for (const entry of entries) {
|
|
23
|
+
const relative = toProjectRelative(root, entry.filepath);
|
|
24
|
+
if (relative.split('/').includes(REFUSED_DIRECTORY)) {
|
|
25
|
+
return yield* askThrowError(askUserScriptBuild.errorType.SourceTooLarge, `[${drive}:${root}] contains a ${REFUSED_DIRECTORY} folder; dependencies are not supported in a user script yet`);
|
|
26
|
+
}
|
|
27
|
+
if (entry.isDir) {
|
|
28
|
+
pending.push(trimSlashes(entry.filepath));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
filePaths.push(entry.filepath);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (filePaths.length > USER_SCRIPT_SOURCE_LIMITS.maxFiles) {
|
|
35
|
+
return yield* askThrowError(askUserScriptBuild.errorType.SourceTooLarge, `[${drive}:${root}] has more than ${USER_SCRIPT_SOURCE_LIMITS.maxFiles} files`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const files = [];
|
|
39
|
+
let totalBytes = 0;
|
|
40
|
+
for (const filepath of filePaths) {
|
|
41
|
+
const text = yield* askFileReadTextContents(drive, filepath, scope);
|
|
42
|
+
totalBytes += Buffer.byteLength(text, 'utf8');
|
|
43
|
+
if (totalBytes > USER_SCRIPT_SOURCE_LIMITS.maxBytes) {
|
|
44
|
+
return yield* askThrowError(askUserScriptBuild.errorType.SourceTooLarge, `[${drive}:${root}] is larger than ${USER_SCRIPT_SOURCE_LIMITS.maxBytes} bytes`);
|
|
45
|
+
}
|
|
46
|
+
files.push({ path: toProjectRelative(root, filepath), text });
|
|
47
|
+
}
|
|
48
|
+
return files;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=askUserScriptCollectSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"askUserScriptCollectSource.js","sourceRoot":"","sources":["../../../../src/actionProcessor/logic/askUserScriptCollectSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAe,aAAa,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAE/H,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAGxE,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAEzC,MAAM,WAAW,GAAG,CAAC,SAAiB,EAAU,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAEvF,MAAM,iBAAiB,GAAG,CAAC,eAAuB,EAAE,QAAgB,EAAU,EAAE;IAC9E,MAAM,MAAM,GAAG,GAAG,eAAe,GAAG,CAAC;IACrC,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S,CAAC,MAAM,GAAG,yBAAyB,CAAC,QAAQ,EAAE,CAAC;YAC1D,OAAO,KAAK,CAAC,CAAC,aAAa,CACzB,kBAAkB,CAAC,SAAS,CAAC,cAAc,EAC3C,IAAI,KAAK,IAAI,IAAI,mBAAmB,yBAAyB,CAAC,QAAQ,QAAQ,CAC/E,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM,KAAK,GAA2B,EAAE,CAAC;IACzC,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,uBAAuB,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QACpE,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC9C,IAAI,UAAU,GAAG,yBAAyB,CAAC,QAAQ,EAAE,CAAC;YACpD,OAAO,KAAK,CAAC,CAAC,aAAa,CACzB,kBAAkB,CAAC,SAAS,CAAC,cAAc,EAC3C,IAAI,KAAK,IAAI,IAAI,oBAAoB,yBAAyB,CAAC,QAAQ,QAAQ,CAChF,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { askFileListAllDirectory, askFileReadTextContents, AskResponse, askThrowError, askUserScriptBuild } from '@qpqjs/core';\n\nimport { USER_SCRIPT_SOURCE_LIMITS } from './USER_SCRIPT_SOURCE_LIMITS';\nimport { UserScriptSourceFile } from './UserScriptSourceFile';\n\nconst REFUSED_DIRECTORY = 'node_modules';\n\nconst trimSlashes = (directory: string): string => directory.replace(/^\\/+|\\/+$/g, '');\n\nconst toProjectRelative = (sourceDirectory: string, filepath: string): string => {\n const prefix = `${sourceDirectory}/`;\n return filepath.startsWith(prefix) ? filepath.slice(prefix.length) : filepath;\n};\n\n/**\n * Reads a script project off a drive: every file under `sourceDirectory`, recursively, as\n * text with paths relative to the project root. Refuses a node_modules folder and enforces\n * USER_SCRIPT_SOURCE_LIMITS, both as the build action's SourceTooLarge. Listing and read\n * failures propagate with their own types for the processor to re-label.\n */\nexport function* askUserScriptCollectSource(drive: string, sourceDirectory: string, scope?: string): AskResponse<UserScriptSourceFile[]> {\n const root = trimSlashes(sourceDirectory);\n const pending: string[] = [root];\n const filePaths: string[] = [];\n\n while (pending.length > 0) {\n const directory = pending.shift() as string;\n const entries = yield* askFileListAllDirectory(drive, directory, scope);\n\n for (const entry of entries) {\n const relative = toProjectRelative(root, entry.filepath);\n if (relative.split('/').includes(REFUSED_DIRECTORY)) {\n return yield* askThrowError(\n askUserScriptBuild.errorType.SourceTooLarge,\n `[${drive}:${root}] contains a ${REFUSED_DIRECTORY} folder; dependencies are not supported in a user script yet`,\n );\n }\n\n if (entry.isDir) {\n pending.push(trimSlashes(entry.filepath));\n } else {\n filePaths.push(entry.filepath);\n }\n }\n\n if (filePaths.length > USER_SCRIPT_SOURCE_LIMITS.maxFiles) {\n return yield* askThrowError(\n askUserScriptBuild.errorType.SourceTooLarge,\n `[${drive}:${root}] has more than ${USER_SCRIPT_SOURCE_LIMITS.maxFiles} files`,\n );\n }\n }\n\n const files: UserScriptSourceFile[] = [];\n let totalBytes = 0;\n for (const filepath of filePaths) {\n const text = yield* askFileReadTextContents(drive, filepath, scope);\n totalBytes += Buffer.byteLength(text, 'utf8');\n if (totalBytes > USER_SCRIPT_SOURCE_LIMITS.maxBytes) {\n return yield* askThrowError(\n askUserScriptBuild.errorType.SourceTooLarge,\n `[${drive}:${root}] is larger than ${USER_SCRIPT_SOURCE_LIMITS.maxBytes} bytes`,\n );\n }\n files.push({ path: toProjectRelative(root, filepath), text });\n }\n\n return files;\n}\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { AskResponse } from '@qpqjs/core';
|
|
2
|
+
/** Writes a built script to exactly `outputFilepath` on a drive; a build publishes nothing else. */
|
|
3
|
+
export declare function askUserScriptPublishOutput(drive: string, outputFilepath: string, script: string, scope?: string): AskResponse<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { askFileWriteTextContents } from '@qpqjs/core';
|
|
2
|
+
/** Writes a built script to exactly `outputFilepath` on a drive; a build publishes nothing else. */
|
|
3
|
+
export function* askUserScriptPublishOutput(drive, outputFilepath, script, scope) {
|
|
4
|
+
yield* askFileWriteTextContents(drive, outputFilepath, script, undefined, scope);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=askUserScriptPublishOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"askUserScriptPublishOutput.js","sourceRoot":"","sources":["../../../../src/actionProcessor/logic/askUserScriptPublishOutput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAe,MAAM,aAAa,CAAC;AAEpE,oGAAoG;AACpG,MAAM,SAAS,CAAC,CAAC,0BAA0B,CAAC,KAAa,EAAE,cAAsB,EAAE,MAAc,EAAE,KAAc;IAC/G,KAAK,CAAC,CAAC,wBAAwB,CAAC,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;AACnF,CAAC","sourcesContent":["import { askFileWriteTextContents, AskResponse } from '@qpqjs/core';\n\n/** Writes a built script to exactly `outputFilepath` on a drive; a build publishes nothing else. */\nexport function* askUserScriptPublishOutput(drive: string, outputFilepath: string, script: string, scope?: string): AskResponse<void> {\n yield* askFileWriteTextContents(drive, outputFilepath, script, undefined, scope);\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UserScriptModuleMap } from '@qpqjs/actionprocessor-node';
|
|
2
|
+
import { BuiltUserScript } from './BuiltUserScript';
|
|
3
|
+
/**
|
|
4
|
+
* The part of a platform build that is the same whatever the source is: a temp project
|
|
5
|
+
* directory that `materialise` fills, the build, the output read back, and the temp
|
|
6
|
+
* directory removed whatever happened. Errors from `materialise` and from the build
|
|
7
|
+
* propagate for the caller to map.
|
|
8
|
+
*/
|
|
9
|
+
export declare const buildUserScriptInTempDir: (materialise: (projectDir: string) => Promise<void> | void, sourceMap: boolean, hostModules: UserScriptModuleMap) => Promise<BuiltUserScript>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import os from 'os';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { buildUserScript } from '../../build/buildUserScript';
|
|
5
|
+
/**
|
|
6
|
+
* The part of a platform build that is the same whatever the source is: a temp project
|
|
7
|
+
* directory that `materialise` fills, the build, the output read back, and the temp
|
|
8
|
+
* directory removed whatever happened. Errors from `materialise` and from the build
|
|
9
|
+
* propagate for the caller to map.
|
|
10
|
+
*/
|
|
11
|
+
export const buildUserScriptInTempDir = async (materialise, sourceMap, hostModules) => {
|
|
12
|
+
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'qpq-user-script-'));
|
|
13
|
+
const projectDir = path.join(tempDir, 'project');
|
|
14
|
+
const outDir = path.join(tempDir, 'out');
|
|
15
|
+
try {
|
|
16
|
+
fs.mkdirSync(projectDir, { recursive: true });
|
|
17
|
+
await materialise(projectDir);
|
|
18
|
+
const result = await buildUserScript({ projectDir, outDir, sourceMap, hostModules });
|
|
19
|
+
return { script: fs.readFileSync(result.entryPath, 'utf8') };
|
|
20
|
+
}
|
|
21
|
+
finally {
|
|
22
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=buildUserScriptInTempDir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildUserScriptInTempDir.js","sourceRoot":"","sources":["../../../../src/actionProcessor/logic/buildUserScriptInTempDir.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAG9D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,EAC3C,WAAyD,EACzD,SAAkB,EAClB,WAAgC,EACN,EAAE;IAC5B,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAC3E,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAEzC,IAAI,CAAC;QACH,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,MAAM,WAAW,CAAC,UAAU,CAAC,CAAC;QAC9B,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;QAErF,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC;IAC/D,CAAC;YAAS,CAAC;QACT,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { UserScriptModuleMap } from '@qpqjs/actionprocessor-node';\n\nimport fs from 'fs';\nimport os from 'os';\nimport path from 'path';\n\nimport { buildUserScript } from '../../build/buildUserScript';\nimport { BuiltUserScript } from './BuiltUserScript';\n\n/**\n * The part of a platform build that is the same whatever the source is: a temp project\n * directory that `materialise` fills, the build, the output read back, and the temp\n * directory removed whatever happened. Errors from `materialise` and from the build\n * propagate for the caller to map.\n */\nexport const buildUserScriptInTempDir = async (\n materialise: (projectDir: string) => Promise<void> | void,\n sourceMap: boolean,\n hostModules: UserScriptModuleMap,\n): Promise<BuiltUserScript> => {\n const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'qpq-user-script-'));\n const projectDir = path.join(tempDir, 'project');\n const outDir = path.join(tempDir, 'out');\n\n try {\n fs.mkdirSync(projectDir, { recursive: true });\n await materialise(projectDir);\n const result = await buildUserScript({ projectDir, outDir, sourceMap, hostModules });\n\n return { script: fs.readFileSync(result.entryPath, 'utf8') };\n } finally {\n fs.rmSync(tempDir, { recursive: true, force: true });\n }\n};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unpacks a user-controlled zip into the project directory under the same rules as a
|
|
3
|
+
* directory build: plain relative paths only, no symlinks, no node_modules, at most
|
|
4
|
+
* USER_SCRIPT_SOURCE_LIMITS files and unpacked bytes counted as they are written (the
|
|
5
|
+
* sizes in the zip's headers are never trusted). Directory entries are ignored; folders
|
|
6
|
+
* come from file paths. Returns the project-relative paths written.
|
|
7
|
+
*/
|
|
8
|
+
export declare const extractUserScriptZip: (zip: Buffer, projectDir: string) => Promise<string[]>;
|