@factorialco/fcode-cli 1.1.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 +1021 -0
- package/bin/dev +17 -0
- package/bin/dev.cmd +3 -0
- package/bin/run +7 -0
- package/bin/run.cmd +3 -0
- package/dist/commands/add.d.ts +6 -0
- package/dist/commands/add.js +22 -0
- package/dist/commands/clone.d.ts +26 -0
- package/dist/commands/clone.js +177 -0
- package/dist/commands/dependencies/add.d.ts +9 -0
- package/dist/commands/dependencies/add.js +13 -0
- package/dist/commands/dependencies/install.d.ts +14 -0
- package/dist/commands/dependencies/install.js +44 -0
- package/dist/commands/dependencies/pull.d.ts +12 -0
- package/dist/commands/dependencies/pull.js +14 -0
- package/dist/commands/dependencies/push.d.ts +12 -0
- package/dist/commands/dependencies/push.js +14 -0
- package/dist/commands/dependencies/reset.d.ts +9 -0
- package/dist/commands/dependencies/reset.js +13 -0
- package/dist/commands/dependencies/status.d.ts +9 -0
- package/dist/commands/dependencies/status.js +13 -0
- package/dist/commands/http.d.ts +22 -0
- package/dist/commands/http.js +272 -0
- package/dist/commands/login.d.ts +18 -0
- package/dist/commands/login.js +62 -0
- package/dist/commands/logout.d.ts +10 -0
- package/dist/commands/logout.js +34 -0
- package/dist/commands/modules/add.d.ts +9 -0
- package/dist/commands/modules/add.js +13 -0
- package/dist/commands/modules/pull.d.ts +13 -0
- package/dist/commands/modules/pull.js +43 -0
- package/dist/commands/modules/push.d.ts +13 -0
- package/dist/commands/modules/push.js +35 -0
- package/dist/commands/modules/remove.d.ts +9 -0
- package/dist/commands/modules/remove.js +19 -0
- package/dist/commands/modules/reset.d.ts +9 -0
- package/dist/commands/modules/reset.js +13 -0
- package/dist/commands/modules/status.d.ts +11 -0
- package/dist/commands/modules/status.js +40 -0
- package/dist/commands/pre-debug.d.ts +20 -0
- package/dist/commands/pre-debug.js +120 -0
- package/dist/commands/process-metadata.d.ts +18 -0
- package/dist/commands/process-metadata.js +63 -0
- package/dist/commands/processes/add.d.ts +9 -0
- package/dist/commands/processes/add.js +13 -0
- package/dist/commands/processes/install-dependencies.d.ts +14 -0
- package/dist/commands/processes/install-dependencies.js +30 -0
- package/dist/commands/processes/pull.d.ts +13 -0
- package/dist/commands/processes/pull.js +47 -0
- package/dist/commands/processes/push.d.ts +13 -0
- package/dist/commands/processes/push.js +39 -0
- package/dist/commands/processes/remove.d.ts +9 -0
- package/dist/commands/processes/remove.js +19 -0
- package/dist/commands/processes/reset.d.ts +9 -0
- package/dist/commands/processes/reset.js +13 -0
- package/dist/commands/processes/status.d.ts +11 -0
- package/dist/commands/processes/status.js +58 -0
- package/dist/commands/pull.d.ts +9 -0
- package/dist/commands/pull.js +32 -0
- package/dist/commands/push.d.ts +9 -0
- package/dist/commands/push.js +29 -0
- package/dist/commands/remote/add.d.ts +10 -0
- package/dist/commands/remote/add.js +32 -0
- package/dist/commands/remote/list.d.ts +7 -0
- package/dist/commands/remote/list.js +33 -0
- package/dist/commands/remote/set.d.ts +10 -0
- package/dist/commands/remote/set.js +28 -0
- package/dist/commands/reset.d.ts +6 -0
- package/dist/commands/reset.js +19 -0
- package/dist/commands/run.d.ts +16 -0
- package/dist/commands/run.js +56 -0
- package/dist/commands/runtime-env.d.ts +12 -0
- package/dist/commands/runtime-env.js +42 -0
- package/dist/commands/settings/get.d.ts +12 -0
- package/dist/commands/settings/get.js +67 -0
- package/dist/commands/settings/remove.d.ts +9 -0
- package/dist/commands/settings/remove.js +35 -0
- package/dist/commands/settings/set.d.ts +10 -0
- package/dist/commands/settings/set.js +39 -0
- package/dist/commands/setup-debug.d.ts +12 -0
- package/dist/commands/setup-debug.js +118 -0
- package/dist/commands/status.d.ts +6 -0
- package/dist/commands/status.js +22 -0
- package/dist/commands/team/pull.d.ts +8 -0
- package/dist/commands/team/pull.js +23 -0
- package/dist/commands/team/push.d.ts +11 -0
- package/dist/commands/team/push.js +41 -0
- package/dist/commands/team/status.d.ts +8 -0
- package/dist/commands/team/status.js +40 -0
- package/dist/commands/test/scaffold.d.ts +9 -0
- package/dist/commands/test/scaffold.js +61 -0
- package/dist/commands/test.d.ts +13 -0
- package/dist/commands/test.js +72 -0
- package/dist/commands/variables/add.d.ts +12 -0
- package/dist/commands/variables/add.js +21 -0
- package/dist/commands/variables/pull.d.ts +12 -0
- package/dist/commands/variables/pull.js +14 -0
- package/dist/commands/variables/push.d.ts +12 -0
- package/dist/commands/variables/push.js +14 -0
- package/dist/commands/variables/remove.d.ts +9 -0
- package/dist/commands/variables/remove.js +19 -0
- package/dist/commands/variables/reset.d.ts +9 -0
- package/dist/commands/variables/reset.js +13 -0
- package/dist/commands/variables/status.d.ts +12 -0
- package/dist/commands/variables/status.js +58 -0
- package/dist/config/global.d.ts +15 -0
- package/dist/config/global.js +77 -0
- package/dist/config/index.d.ts +14 -0
- package/dist/config/index.js +44 -0
- package/dist/config/remote.d.ts +15 -0
- package/dist/config/remote.js +60 -0
- package/dist/config/settings.d.ts +16 -0
- package/dist/config/settings.js +54 -0
- package/dist/config/workspace.d.ts +28 -0
- package/dist/config/workspace.js +158 -0
- package/dist/core/commands/api-client-command.d.ts +6 -0
- package/dist/core/commands/api-client-command.js +30 -0
- package/dist/core/commands/base-command.d.ts +11 -0
- package/dist/core/commands/base-command.js +61 -0
- package/dist/core/commands/dependency-command.d.ts +5 -0
- package/dist/core/commands/dependency-command.js +16 -0
- package/dist/core/commands/modules-command.d.ts +7 -0
- package/dist/core/commands/modules-command.js +18 -0
- package/dist/core/commands/processes-command.d.ts +8 -0
- package/dist/core/commands/processes-command.js +27 -0
- package/dist/core/commands/resource-command.d.ts +24 -0
- package/dist/core/commands/resource-command.js +92 -0
- package/dist/core/commands/variables-command.d.ts +5 -0
- package/dist/core/commands/variables-command.js +16 -0
- package/dist/core/dependencies/env-dependencies-command.d.ts +19 -0
- package/dist/core/dependencies/env-dependencies-command.js +70 -0
- package/dist/core/dependencies/env-process-dependencies-command.d.ts +15 -0
- package/dist/core/dependencies/env-process-dependencies-command.js +78 -0
- package/dist/core/dependencies/javascript-env-dependencies.d.ts +8 -0
- package/dist/core/dependencies/javascript-env-dependencies.js +77 -0
- package/dist/core/dependencies/python-env-dependencies.d.ts +9 -0
- package/dist/core/dependencies/python-env-dependencies.js +91 -0
- package/dist/core/errors.d.ts +55 -0
- package/dist/core/errors.js +144 -0
- package/dist/core/executors/execution-task.d.ts +29 -0
- package/dist/core/executors/execution-task.js +139 -0
- package/dist/core/executors/javascript-execution-task.d.ts +13 -0
- package/dist/core/executors/javascript-execution-task.js +618 -0
- package/dist/core/executors/python/context.d.ts +2 -0
- package/dist/core/executors/python/context.js +3 -0
- package/dist/core/executors/python/datastore.d.ts +2 -0
- package/dist/core/executors/python/datastore.js +4 -0
- package/dist/core/executors/python-execution-task.d.ts +11 -0
- package/dist/core/executors/python-execution-task.js +173 -0
- package/dist/core/executors/source-code-sanitizer.d.ts +4 -0
- package/dist/core/executors/source-code-sanitizer.js +45 -0
- package/dist/core/resource-merger.d.ts +14 -0
- package/dist/core/resource-merger.js +155 -0
- package/dist/core/resource-pusher.d.ts +12 -0
- package/dist/core/resource-pusher.js +133 -0
- package/dist/core/resource-repository.d.ts +8 -0
- package/dist/core/resource-repository.js +2 -0
- package/dist/core/types.d.ts +290 -0
- package/dist/core/types.js +238 -0
- package/dist/core/utils/dependencies.d.ts +5 -0
- package/dist/core/utils/dependencies.js +82 -0
- package/dist/core/utils/variables.d.ts +4 -0
- package/dist/core/utils/variables.js +10 -0
- package/dist/hooks/init/auth.d.ts +3 -0
- package/dist/hooks/init/auth.js +28 -0
- package/dist/hooks/init/update.d.ts +3 -0
- package/dist/hooks/init/update.js +42 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -0
- package/dist/repositories/process.d.ts +36 -0
- package/dist/repositories/process.js +339 -0
- package/dist/repositories/programming-language-manifest.d.ts +17 -0
- package/dist/repositories/programming-language-manifest.js +95 -0
- package/dist/repositories/resource.d.ts +29 -0
- package/dist/repositories/resource.js +79 -0
- package/dist/repositories/script-library.d.ts +28 -0
- package/dist/repositories/script-library.js +164 -0
- package/dist/repositories/team.d.ts +23 -0
- package/dist/repositories/team.js +74 -0
- package/dist/repositories/variable.d.ts +26 -0
- package/dist/repositories/variable.js +174 -0
- package/dist/runtime/executor.js +87 -0
- package/dist/runtime/executor.py +81 -0
- package/dist/runtime/libs/node/fcode/index.js +1 -0
- package/dist/runtime/libs/python/fcode/__init__.py +75 -0
- package/dist/runtime/libs/python/fcode/context.py +98 -0
- package/dist/runtime/libs/python/fcode/datastore.py +35 -0
- package/dist/runtime/libs/python/fcode/schedule.py +45 -0
- package/dist/runtime/libs/python/fcode/storage.py +271 -0
- package/dist/runtime/libs/python/fcode/variables.py +102 -0
- package/dist/services/auth-service.d.ts +12 -0
- package/dist/services/auth-service.js +114 -0
- package/dist/services/credential-prompter.d.ts +6 -0
- package/dist/services/credential-prompter.js +60 -0
- package/dist/services/fcode-graphql-client.d.ts +45 -0
- package/dist/services/fcode-graphql-client.js +721 -0
- package/dist/services/http-server.d.ts +3 -0
- package/dist/services/http-server.js +17 -0
- package/dist/services/oauth-browser-service.d.ts +9 -0
- package/dist/services/oauth-browser-service.js +164 -0
- package/dist/services/process-parameters-sampler.d.ts +2 -0
- package/dist/services/process-parameters-sampler.js +41 -0
- package/dist/services/process-runner.d.ts +22 -0
- package/dist/services/process-runner.js +97 -0
- package/dist/services/resource-checker.d.ts +8 -0
- package/dist/services/resource-checker.js +82 -0
- package/dist/services/test-runner.d.ts +17 -0
- package/dist/services/test-runner.js +228 -0
- package/dist/utils/canonical-hash.d.ts +9 -0
- package/dist/utils/canonical-hash.js +30 -0
- package/dist/utils/cli/index.d.ts +14 -0
- package/dist/utils/cli/index.js +50 -0
- package/dist/utils/cli/screen.d.ts +2 -0
- package/dist/utils/cli/screen.js +25 -0
- package/dist/utils/cli/styled/table.d.ts +23 -0
- package/dist/utils/cli/styled/table.js +272 -0
- package/dist/utils/colorize-resource.d.ts +1 -0
- package/dist/utils/colorize-resource.js +7 -0
- package/dist/utils/env-utils.d.ts +2 -0
- package/dist/utils/env-utils.js +16 -0
- package/dist/utils/file-utils.d.ts +11 -0
- package/dist/utils/file-utils.js +33 -0
- package/dist/utils/filenamify.d.ts +4 -0
- package/dist/utils/filenamify.js +73 -0
- package/dist/utils/gitignore.d.ts +17 -0
- package/dist/utils/gitignore.js +60 -0
- package/dist/utils/promise.d.ts +4 -0
- package/dist/utils/promise.js +38 -0
- package/dist/utils/url-utils.d.ts +2 -0
- package/dist/utils/url-utils.js +10 -0
- package/dist/utils/variable-warnings.d.ts +8 -0
- package/dist/utils/variable-warnings.js +38 -0
- package/oclif.manifest.json +1783 -0
- package/package.json +129 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.escapeEnvValue = escapeEnvValue;
|
|
4
|
+
exports.unescapeEnvValue = unescapeEnvValue;
|
|
5
|
+
function escapeEnvValue(value) {
|
|
6
|
+
if (value.includes('\n') || value.includes("'")) {
|
|
7
|
+
return `'${value.replaceAll('\\', '\\\\').replaceAll("'", "\\'")}'`;
|
|
8
|
+
}
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
function unescapeEnvValue(value) {
|
|
12
|
+
if (value.includes('\n') || value.includes("'")) {
|
|
13
|
+
return value.replace(/\\([\s\S])/g, '$1');
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writes content to a file only if the content differs from what's already in the file.
|
|
3
|
+
*
|
|
4
|
+
* When `readOnly` is set, the file is left read-only (0o444); a previously read-only file
|
|
5
|
+
* is unlocked before being overwritten so re-pulling an inherited resource doesn't fail
|
|
6
|
+
* with EACCES, and is unlocked back to 0o644 when the resource stops being inherited.
|
|
7
|
+
* Owned (writable) files keep their existing mode, matching the previous behavior.
|
|
8
|
+
*/
|
|
9
|
+
export declare function outputFileSyncIfChanged(filePath: string, content: string, { readOnly }?: {
|
|
10
|
+
readOnly?: boolean;
|
|
11
|
+
}): void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.outputFileSyncIfChanged = outputFileSyncIfChanged;
|
|
4
|
+
const fs = require("fs-extra");
|
|
5
|
+
/**
|
|
6
|
+
* Writes content to a file only if the content differs from what's already in the file.
|
|
7
|
+
*
|
|
8
|
+
* When `readOnly` is set, the file is left read-only (0o444); a previously read-only file
|
|
9
|
+
* is unlocked before being overwritten so re-pulling an inherited resource doesn't fail
|
|
10
|
+
* with EACCES, and is unlocked back to 0o644 when the resource stops being inherited.
|
|
11
|
+
* Owned (writable) files keep their existing mode, matching the previous behavior.
|
|
12
|
+
*/
|
|
13
|
+
function outputFileSyncIfChanged(filePath, content, { readOnly = false } = {}) {
|
|
14
|
+
const exists = fs.existsSync(filePath);
|
|
15
|
+
const isReadOnly = exists && (fs.statSync(filePath).mode & 0o200) === 0;
|
|
16
|
+
const changed = !exists || fs.readFileSync(filePath).toString() !== content;
|
|
17
|
+
if (!changed) {
|
|
18
|
+
if (readOnly && !isReadOnly) {
|
|
19
|
+
fs.chmodSync(filePath, 0o444);
|
|
20
|
+
}
|
|
21
|
+
else if (!readOnly && isReadOnly) {
|
|
22
|
+
fs.chmodSync(filePath, 0o644);
|
|
23
|
+
}
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (isReadOnly) {
|
|
27
|
+
fs.chmodSync(filePath, 0o644);
|
|
28
|
+
}
|
|
29
|
+
fs.outputFileSync(filePath, content);
|
|
30
|
+
if (readOnly) {
|
|
31
|
+
fs.chmodSync(filePath, 0o444);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = filenamify;
|
|
4
|
+
const MAX_FILENAME_LENGTH = 100;
|
|
5
|
+
const reControlChars = /[\u0000-\u001F\u0080-\u009F]/g; // eslint-disable-line no-control-regex
|
|
6
|
+
const reRelativePath = /^\.+/;
|
|
7
|
+
const reTrailingPeriods = /\.+$/;
|
|
8
|
+
function escapeStringRegexp(string) {
|
|
9
|
+
if (typeof string !== 'string') {
|
|
10
|
+
throw new TypeError('Expected a string');
|
|
11
|
+
}
|
|
12
|
+
// Escape characters with special meaning either inside or outside character sets.
|
|
13
|
+
// Use a simple backslash escape when it’s always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
|
|
14
|
+
return string.replaceAll(/[$()*+.?[\\\]^{|}]/g, '\\$&').replaceAll('-', '\\x2d');
|
|
15
|
+
}
|
|
16
|
+
function trimRepeated(string, target) {
|
|
17
|
+
if (typeof string !== 'string' || typeof target !== 'string') {
|
|
18
|
+
throw new TypeError('Expected a string');
|
|
19
|
+
}
|
|
20
|
+
const regex = new RegExp(`(?:${escapeStringRegexp(target)}){2,}`, 'g');
|
|
21
|
+
return string.replace(regex, target);
|
|
22
|
+
}
|
|
23
|
+
function filenameReservedRegex() {
|
|
24
|
+
return /[\t"*/:<>?\\|]/g;
|
|
25
|
+
}
|
|
26
|
+
function windowsReservedNameRegex() {
|
|
27
|
+
return /^(con|prn|aux|nul|com\d|lpt\d)$/i;
|
|
28
|
+
}
|
|
29
|
+
function stripOuter(string, substring) {
|
|
30
|
+
if (typeof string !== 'string' || typeof substring !== 'string') {
|
|
31
|
+
throw new TypeError('Expected a string');
|
|
32
|
+
}
|
|
33
|
+
if (string.startsWith(substring)) {
|
|
34
|
+
string = string.slice(substring.length);
|
|
35
|
+
}
|
|
36
|
+
if (string.endsWith(substring)) {
|
|
37
|
+
string = string.slice(0, -substring.length);
|
|
38
|
+
}
|
|
39
|
+
return string;
|
|
40
|
+
}
|
|
41
|
+
function filenamify(string, options = {}) {
|
|
42
|
+
if (typeof string !== 'string') {
|
|
43
|
+
throw new TypeError('Expected a string');
|
|
44
|
+
}
|
|
45
|
+
const replacement = options.replacement === undefined ? '!' : options.replacement;
|
|
46
|
+
if (filenameReservedRegex().test(replacement) &&
|
|
47
|
+
reControlChars.test(replacement)) {
|
|
48
|
+
throw new Error('Replacement string cannot contain reserved filename characters');
|
|
49
|
+
}
|
|
50
|
+
string = string.normalize('NFD');
|
|
51
|
+
string = string.replace(filenameReservedRegex(), replacement);
|
|
52
|
+
string = string.replaceAll(reControlChars, replacement);
|
|
53
|
+
string = string.replace(reRelativePath, replacement);
|
|
54
|
+
string = string.replace(reTrailingPeriods, '');
|
|
55
|
+
if (replacement.length > 0) {
|
|
56
|
+
string = trimRepeated(string, replacement);
|
|
57
|
+
string = string.length > 1 ? stripOuter(string, replacement) : string;
|
|
58
|
+
}
|
|
59
|
+
string = windowsReservedNameRegex().test(string)
|
|
60
|
+
? string + replacement
|
|
61
|
+
: string;
|
|
62
|
+
const allowedLength = typeof options.maxLength === 'number'
|
|
63
|
+
? options.maxLength
|
|
64
|
+
: MAX_FILENAME_LENGTH;
|
|
65
|
+
if (string.length > allowedLength) {
|
|
66
|
+
const extensionIndex = string.lastIndexOf('.');
|
|
67
|
+
const filename = extensionIndex === -1 ? string : string.slice(0, extensionIndex);
|
|
68
|
+
const extension = extensionIndex === -1 ? '' : string.slice(extensionIndex);
|
|
69
|
+
string =
|
|
70
|
+
filename.slice(0, Math.min(allowedLength, filename.length)) + extension;
|
|
71
|
+
}
|
|
72
|
+
return string;
|
|
73
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const INHERITED_BLOCK_START = "# BEGIN fcode inherited resources (auto-generated, do not edit)";
|
|
2
|
+
export declare const INHERITED_BLOCK_END = "# END fcode inherited resources";
|
|
3
|
+
/**
|
|
4
|
+
* Rebuilds the managed "inherited resources" block in a .gitignore.
|
|
5
|
+
*
|
|
6
|
+
* Any existing managed block (between the markers, inclusive) is stripped, and a
|
|
7
|
+
* freshly rendered block listing the sorted inherited paths is appended when there
|
|
8
|
+
* are any. All other lines are preserved verbatim. The output is idempotent:
|
|
9
|
+
* rendering the same input twice yields the same result.
|
|
10
|
+
*/
|
|
11
|
+
export declare function renderGitignoreWithInherited(existing: string, inheritedPaths: string[]): string;
|
|
12
|
+
/**
|
|
13
|
+
* Refreshes the workspace .gitignore so inherited processes/modules (owned by a
|
|
14
|
+
* parent team and pulled read-only) are not tracked by git. Regenerated from the
|
|
15
|
+
* current workspace metadata, so resources that stop being inherited drop out.
|
|
16
|
+
*/
|
|
17
|
+
export declare function syncInheritedGitignore(workspaceDir?: string): Promise<void>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.INHERITED_BLOCK_END = exports.INHERITED_BLOCK_START = void 0;
|
|
4
|
+
exports.renderGitignoreWithInherited = renderGitignoreWithInherited;
|
|
5
|
+
exports.syncInheritedGitignore = syncInheritedGitignore;
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
const fs = require("fs-extra");
|
|
8
|
+
const workspace_1 = require("../config/workspace");
|
|
9
|
+
const filenamify_1 = require("./filenamify");
|
|
10
|
+
const file_utils_1 = require("./file-utils");
|
|
11
|
+
exports.INHERITED_BLOCK_START = '# BEGIN fcode inherited resources (auto-generated, do not edit)';
|
|
12
|
+
exports.INHERITED_BLOCK_END = '# END fcode inherited resources';
|
|
13
|
+
/**
|
|
14
|
+
* Rebuilds the managed "inherited resources" block in a .gitignore.
|
|
15
|
+
*
|
|
16
|
+
* Any existing managed block (between the markers, inclusive) is stripped, and a
|
|
17
|
+
* freshly rendered block listing the sorted inherited paths is appended when there
|
|
18
|
+
* are any. All other lines are preserved verbatim. The output is idempotent:
|
|
19
|
+
* rendering the same input twice yields the same result.
|
|
20
|
+
*/
|
|
21
|
+
function renderGitignoreWithInherited(existing, inheritedPaths) {
|
|
22
|
+
const base = stripManagedBlock(existing).replace(/\n+$/, '');
|
|
23
|
+
if (inheritedPaths.length === 0) {
|
|
24
|
+
return base ? base + '\n' : '';
|
|
25
|
+
}
|
|
26
|
+
const block = [exports.INHERITED_BLOCK_START, ...[...inheritedPaths].sort(), exports.INHERITED_BLOCK_END].join('\n');
|
|
27
|
+
return (base ? base + '\n\n' : '') + block + '\n';
|
|
28
|
+
}
|
|
29
|
+
function stripManagedBlock(content) {
|
|
30
|
+
const lines = content.split('\n');
|
|
31
|
+
const start = lines.indexOf(exports.INHERITED_BLOCK_START);
|
|
32
|
+
if (start === -1) {
|
|
33
|
+
return content;
|
|
34
|
+
}
|
|
35
|
+
const end = lines.indexOf(exports.INHERITED_BLOCK_END, start);
|
|
36
|
+
if (end === -1) {
|
|
37
|
+
return content;
|
|
38
|
+
}
|
|
39
|
+
lines.splice(start, end - start + 1);
|
|
40
|
+
return lines.join('\n');
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Refreshes the workspace .gitignore so inherited processes/modules (owned by a
|
|
44
|
+
* parent team and pulled read-only) are not tracked by git. Regenerated from the
|
|
45
|
+
* current workspace metadata, so resources that stop being inherited drop out.
|
|
46
|
+
*/
|
|
47
|
+
async function syncInheritedGitignore(workspaceDir = process.cwd()) {
|
|
48
|
+
const team = await new workspace_1.default(workspaceDir).getActiveTeam();
|
|
49
|
+
const inheritedPaths = [
|
|
50
|
+
...Object.values(team.processes)
|
|
51
|
+
.filter((process) => process.resolvingTeamSlug)
|
|
52
|
+
.map((process) => `processes/${(0, filenamify_1.default)(process.slug)}/`),
|
|
53
|
+
...Object.values(team.modules)
|
|
54
|
+
.filter((module) => module.resolvingTeamSlug)
|
|
55
|
+
.map((module) => `modules/${(0, filenamify_1.default)(module.name)}/`),
|
|
56
|
+
];
|
|
57
|
+
const gitignorePath = path.join(workspaceDir, '.gitignore');
|
|
58
|
+
const existing = fs.existsSync(gitignorePath) ? fs.readFileSync(gitignorePath, 'utf8') : '';
|
|
59
|
+
(0, file_utils_1.outputFileSyncIfChanged)(gitignorePath, renderGitignoreWithInherited(existing, inheritedPaths));
|
|
60
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function chainedPromises<T>(items: Array<T>, action: (item: T) => Promise<T>): Promise<Array<T>>;
|
|
2
|
+
export declare function chainedPromisesWithConfirmation<T>(items: Array<T>, confirmation: (promise: T) => Promise<boolean>, force?: boolean): Promise<Array<T>>;
|
|
3
|
+
export declare function chainedPromisesWithArgs<T>(promises: Array<T>, action: (item: T) => Promise<T>): Promise<Array<T>>;
|
|
4
|
+
export declare function chainedPromisesWithConfirmationAndArgs<T>(promises: Array<T>, confirmation: (promise: T) => Promise<boolean>, force?: boolean): Promise<Array<T>>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chainedPromises = chainedPromises;
|
|
4
|
+
exports.chainedPromisesWithConfirmation = chainedPromisesWithConfirmation;
|
|
5
|
+
exports.chainedPromisesWithArgs = chainedPromisesWithArgs;
|
|
6
|
+
exports.chainedPromisesWithConfirmationAndArgs = chainedPromisesWithConfirmationAndArgs;
|
|
7
|
+
async function chainedPromises(items, action) {
|
|
8
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
9
|
+
return items.reduce((previousPromise, currentItem) => previousPromise.then(async (results) => {
|
|
10
|
+
await action(currentItem);
|
|
11
|
+
return [...results, currentItem];
|
|
12
|
+
}), Promise.resolve([]));
|
|
13
|
+
}
|
|
14
|
+
async function chainedPromisesWithConfirmation(items, confirmation, force) {
|
|
15
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
16
|
+
return items.reduce((previousPromise, currentItem) => previousPromise.then(async (confirmedItems) => {
|
|
17
|
+
if (force || (await confirmation(currentItem))) {
|
|
18
|
+
return [...confirmedItems, currentItem];
|
|
19
|
+
}
|
|
20
|
+
return confirmedItems;
|
|
21
|
+
}), Promise.resolve([]));
|
|
22
|
+
}
|
|
23
|
+
async function chainedPromisesWithArgs(promises, action) {
|
|
24
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
25
|
+
return promises.reduce((previousPromise, currentItem) => previousPromise.then(async (results) => {
|
|
26
|
+
await action(currentItem);
|
|
27
|
+
return [...results, currentItem];
|
|
28
|
+
}), Promise.resolve([]));
|
|
29
|
+
}
|
|
30
|
+
async function chainedPromisesWithConfirmationAndArgs(promises, confirmation, force) {
|
|
31
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
32
|
+
return promises.reduce((previousPromise, currentItem) => previousPromise.then(async (confirmedItems) => {
|
|
33
|
+
if (force || (await confirmation(currentItem))) {
|
|
34
|
+
return [...confirmedItems, currentItem];
|
|
35
|
+
}
|
|
36
|
+
return confirmedItems;
|
|
37
|
+
}), Promise.resolve([]));
|
|
38
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildAuthUrl = buildAuthUrl;
|
|
4
|
+
exports.isDefaultAuthUrl = isDefaultAuthUrl;
|
|
5
|
+
function buildAuthUrl(url) {
|
|
6
|
+
return process.env.FCODE_AUTH_URL || new URL(url).origin + '/auth/realms/fcode';
|
|
7
|
+
}
|
|
8
|
+
function isDefaultAuthUrl(authUrl, baseUrl) {
|
|
9
|
+
return authUrl === buildAuthUrl(baseUrl);
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Variable } from '../core/types';
|
|
2
|
+
export declare function sensitivityChangedVariables(localVariables: Array<Variable>, remoteVariables: Array<Variable>): Array<Variable>;
|
|
3
|
+
export declare function isTamperedSensitive(variable: {
|
|
4
|
+
isSensitive: boolean;
|
|
5
|
+
value: string;
|
|
6
|
+
}): boolean;
|
|
7
|
+
export declare function warnSensitivityChanged(slugs: Array<string>): void;
|
|
8
|
+
export declare function warnTamperedSensitive(slugs: Array<string>, localVariablesFileName: string): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sensitivityChangedVariables = sensitivityChangedVariables;
|
|
4
|
+
exports.isTamperedSensitive = isTamperedSensitive;
|
|
5
|
+
exports.warnSensitivityChanged = warnSensitivityChanged;
|
|
6
|
+
exports.warnTamperedSensitive = warnTamperedSensitive;
|
|
7
|
+
const color_1 = require("@oclif/color");
|
|
8
|
+
const cli_1 = require("./cli");
|
|
9
|
+
const variable_1 = require("../repositories/variable");
|
|
10
|
+
// A sensitive variable whose local isSensitive flag no longer matches remote.
|
|
11
|
+
// isSensitive is immutable, so this is an error the developer must revert.
|
|
12
|
+
function sensitivityChangedVariables(localVariables, remoteVariables) {
|
|
13
|
+
return localVariables.filter((local) => {
|
|
14
|
+
if (!local.id) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const remote = remoteVariables.find((remoteVariable) => remoteVariable.slug === local.slug);
|
|
18
|
+
return remote !== undefined && local.isSensitive !== remote.isSensitive;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
// A sensitive variable whose placeholder in variables.env was replaced with a
|
|
22
|
+
// real value. Sensitive values are immutable there; overrides belong in the
|
|
23
|
+
// local overrides file.
|
|
24
|
+
function isTamperedSensitive(variable) {
|
|
25
|
+
return variable.isSensitive && variable.value !== '' && variable.value !== variable_1.DEFAULT_SENSITIVE_VALUE;
|
|
26
|
+
}
|
|
27
|
+
function warnSensitivityChanged(slugs) {
|
|
28
|
+
for (const slug of slugs) {
|
|
29
|
+
cli_1.default.log(color_1.default.red(`🚫 '${slug}' changed its isSensitive flag in variables.meta.json, but isSensitive is immutable. ` +
|
|
30
|
+
`Revert it to match remote; the change was not pushed.`));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function warnTamperedSensitive(slugs, localVariablesFileName) {
|
|
34
|
+
for (const slug of slugs) {
|
|
35
|
+
cli_1.default.log(color_1.default.yellow(`⚠️ '${slug}' is sensitive and its value cannot be changed in variables.env. ` +
|
|
36
|
+
`To override it locally, set it in ${localVariablesFileName}.`));
|
|
37
|
+
}
|
|
38
|
+
}
|