@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,11 @@
|
|
|
1
|
+
import ApiClientCommand from '../../core/commands/api-client-command';
|
|
2
|
+
import TeamRepository from '../../repositories/team';
|
|
3
|
+
export default class TeamPushCommand extends ApiClientCommand {
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static flags: {
|
|
7
|
+
force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
};
|
|
9
|
+
_teamRepository: TeamRepository;
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const color_1 = require("@oclif/color");
|
|
4
|
+
const api_client_command_1 = require("../../core/commands/api-client-command");
|
|
5
|
+
const team_1 = require("../../repositories/team");
|
|
6
|
+
const types_1 = require("../../core/types");
|
|
7
|
+
const cli_1 = require("../../utils/cli");
|
|
8
|
+
class TeamPushCommand extends api_client_command_1.default {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this._teamRepository = new team_1.default();
|
|
12
|
+
}
|
|
13
|
+
async run() {
|
|
14
|
+
const { flags: { force }, } = await this.parse(TeamPushCommand);
|
|
15
|
+
if (!this._teamRepository.exists()) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
cli_1.default.log(color_1.default.cyan('\n☁️ pushing team settings...'));
|
|
19
|
+
const team = await this._teamRepository.find();
|
|
20
|
+
const storedHash = await this.workspaceConfig.getTeamStoredHash();
|
|
21
|
+
if (!force && storedHash === team.contentHash) {
|
|
22
|
+
cli_1.default.log('Team settings already up to date');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const update = { parentTeamSlugs: team.parentTeamSlugs };
|
|
26
|
+
if (team.zoneId !== undefined) {
|
|
27
|
+
update.zoneId = team.zoneId;
|
|
28
|
+
}
|
|
29
|
+
if (team.errorHandlerConfig) {
|
|
30
|
+
const processId = await this._teamRepository.resolveSlugToId(team.errorHandlerConfig.processSlug);
|
|
31
|
+
update.executionErrorHandlerConfig = { processId, tag: team.errorHandlerConfig.tag ?? null };
|
|
32
|
+
}
|
|
33
|
+
await this._fcodeGraphQLClient.pushTeam(update);
|
|
34
|
+
await this.workspaceConfig.setTeamStoredHash(team.contentHash);
|
|
35
|
+
cli_1.default.log(color_1.default.green('✅ team settings pushed'));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
TeamPushCommand.description = 'Update cloud team settings (timezone, error handler, inheritance) from team.json';
|
|
39
|
+
TeamPushCommand.examples = ['$ fcode team:push'];
|
|
40
|
+
TeamPushCommand.flags = types_1.ForceFlag;
|
|
41
|
+
exports.default = TeamPushCommand;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import ApiClientCommand from '../../core/commands/api-client-command';
|
|
2
|
+
import TeamRepository from '../../repositories/team';
|
|
3
|
+
export default class TeamStatusCommand extends ApiClientCommand {
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
_teamRepository: TeamRepository;
|
|
7
|
+
run(): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const color_1 = require("@oclif/color");
|
|
4
|
+
const api_client_command_1 = require("../../core/commands/api-client-command");
|
|
5
|
+
const team_1 = require("../../repositories/team");
|
|
6
|
+
const cli_1 = require("../../utils/cli");
|
|
7
|
+
class TeamStatusCommand extends api_client_command_1.default {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this._teamRepository = new team_1.default();
|
|
11
|
+
}
|
|
12
|
+
async run() {
|
|
13
|
+
await this.parse(TeamStatusCommand);
|
|
14
|
+
cli_1.default.log(color_1.default.cyan('\nteam status'));
|
|
15
|
+
if (!this._teamRepository.exists()) {
|
|
16
|
+
cli_1.default.log('No team.json found');
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const local = await this._teamRepository.find();
|
|
20
|
+
const storedHash = await this.workspaceConfig.getTeamStoredHash();
|
|
21
|
+
const remote = await this._teamRepository.fromRaw(await this._fcodeGraphQLClient.team());
|
|
22
|
+
const localChanged = storedHash !== local.contentHash;
|
|
23
|
+
const remoteChanged = storedHash !== remote.contentHash;
|
|
24
|
+
if (localChanged && remoteChanged) {
|
|
25
|
+
cli_1.default.log(color_1.default.red('🔥 team settings conflict (changed both locally and in the cloud)'));
|
|
26
|
+
}
|
|
27
|
+
else if (localChanged) {
|
|
28
|
+
cli_1.default.log(color_1.default.yellow('🔺 team settings modified locally (run fcode team:push)'));
|
|
29
|
+
}
|
|
30
|
+
else if (remoteChanged) {
|
|
31
|
+
cli_1.default.log(color_1.default.yellow('🔻 team settings out of date (run fcode team:pull)'));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
cli_1.default.log(color_1.default.green('✅ team settings up to date'));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
TeamStatusCommand.description = 'Show whether team settings (timezone, error handler, inheritance) differ from the cloud';
|
|
39
|
+
TeamStatusCommand.examples = ['$ fcode team:status'];
|
|
40
|
+
exports.default = TeamStatusCommand;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class TestScaffold extends Command {
|
|
3
|
+
static args: {
|
|
4
|
+
slug: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
run(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fs = require("node:fs");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
|
+
const core_2 = require("@oclif/core");
|
|
7
|
+
const process_1 = require("../../repositories/process");
|
|
8
|
+
class TestScaffold extends core_2.Command {
|
|
9
|
+
async run() {
|
|
10
|
+
const { args: { slug } } = await this.parse(TestScaffold);
|
|
11
|
+
const processRepository = new process_1.default();
|
|
12
|
+
const fcodeProcess = await processRepository.find(slug);
|
|
13
|
+
const isPython = fcodeProcess.script.programmingLanguage === 'PYTHON';
|
|
14
|
+
const testsDir = path.join(process.cwd(), 'processes', slug, 'tests');
|
|
15
|
+
const testCaseDir = path.join(testsDir, '01-first-test');
|
|
16
|
+
if (fs.existsSync(testCaseDir)) {
|
|
17
|
+
this.error(`Test directory already exists: ${testCaseDir}`);
|
|
18
|
+
}
|
|
19
|
+
fs.mkdirSync(testCaseDir, { recursive: true });
|
|
20
|
+
fs.writeFileSync(path.join(testCaseDir, 'input.json'), JSON.stringify({}, null, 2) + '\n');
|
|
21
|
+
fs.writeFileSync(path.join(testCaseDir, 'output.json'), JSON.stringify({}, null, 2) + '\n');
|
|
22
|
+
const hooksFile = isPython ? 'testHooks.py' : 'testHooks.js';
|
|
23
|
+
const hooksContent = isPython
|
|
24
|
+
? `def before():
|
|
25
|
+
pass
|
|
26
|
+
# fcode.datastore.set("key", "value")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def after():
|
|
30
|
+
pass
|
|
31
|
+
# fcode.datastore.del_("key")
|
|
32
|
+
`
|
|
33
|
+
: `module.exports.before = async function before() {
|
|
34
|
+
// await fcode.datastore.set('key', 'value')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports.after = async function after() {
|
|
38
|
+
// await fcode.datastore.del('key')
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
fs.writeFileSync(path.join(testCaseDir, hooksFile), hooksContent);
|
|
42
|
+
this.log(`Created test scaffold for '${slug}':`);
|
|
43
|
+
this.log(` processes/${slug}/tests/01-first-test/input.json`);
|
|
44
|
+
this.log(` processes/${slug}/tests/01-first-test/output.json`);
|
|
45
|
+
this.log(` processes/${slug}/tests/01-first-test/${hooksFile}`);
|
|
46
|
+
this.log(`\nEdit input.json with the parameters to pass, and output.json with the expected return value.`);
|
|
47
|
+
this.log(`Run with: fcode test ${slug}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
TestScaffold.args = {
|
|
51
|
+
slug: core_1.Args.string({
|
|
52
|
+
description: 'Process slug to scaffold tests for',
|
|
53
|
+
name: 'slug',
|
|
54
|
+
required: true,
|
|
55
|
+
}),
|
|
56
|
+
};
|
|
57
|
+
TestScaffold.description = 'Create a starter test structure for a process';
|
|
58
|
+
TestScaffold.examples = [
|
|
59
|
+
'$ fcode test:scaffold my-process',
|
|
60
|
+
];
|
|
61
|
+
exports.default = TestScaffold;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class Test extends Command {
|
|
3
|
+
static args: {
|
|
4
|
+
slug: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {
|
|
9
|
+
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
jsonLogs: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const core_2 = require("@oclif/core");
|
|
5
|
+
const process_1 = require("../repositories/process");
|
|
6
|
+
const test_runner_1 = require("../services/test-runner");
|
|
7
|
+
class Test extends core_2.Command {
|
|
8
|
+
async run() {
|
|
9
|
+
const { args: { slug }, flags: { logLevel, jsonLogs }, } = await this.parse(Test);
|
|
10
|
+
const processRepository = new process_1.default();
|
|
11
|
+
const options = { logLevel, jsonLogs };
|
|
12
|
+
if (slug) {
|
|
13
|
+
const fcodeProcess = await processRepository.find(slug);
|
|
14
|
+
const suiteResult = await (0, test_runner_1.runProcessTests)(fcodeProcess, options);
|
|
15
|
+
if (suiteResult.results.length === 0) {
|
|
16
|
+
this.log(`No tests found for process '${slug}'. Add a 'tests/' folder under processes/${slug}/.`);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
(0, test_runner_1.printTestResults)([suiteResult]);
|
|
20
|
+
const anyFailed = suiteResult.results.some((r) => !r.passed);
|
|
21
|
+
if (anyFailed)
|
|
22
|
+
this.exit(1);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
const processes = await processRepository.findAll();
|
|
26
|
+
if (processes.length === 0) {
|
|
27
|
+
this.log('No processes found in workspace.');
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const suiteResults = [];
|
|
31
|
+
for (const p of processes) {
|
|
32
|
+
suiteResults.push(await (0, test_runner_1.runProcessTests)(p, options));
|
|
33
|
+
}
|
|
34
|
+
const withTests = suiteResults.filter((s) => s.results.length > 0);
|
|
35
|
+
if (withTests.length === 0) {
|
|
36
|
+
this.log("No tests found. Add a 'tests/' folder to any process directory to get started.");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
(0, test_runner_1.printTestResults)(withTests);
|
|
40
|
+
const anyFailed = withTests.some((s) => s.results.some((r) => !r.passed));
|
|
41
|
+
if (anyFailed)
|
|
42
|
+
this.exit(1);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
Test.args = {
|
|
47
|
+
slug: core_1.Args.string({
|
|
48
|
+
description: 'Process slug (omit to test all processes)',
|
|
49
|
+
name: 'slug',
|
|
50
|
+
required: false,
|
|
51
|
+
}),
|
|
52
|
+
};
|
|
53
|
+
Test.description = 'Run tests for Factorial Code processes';
|
|
54
|
+
Test.examples = [
|
|
55
|
+
'$ fcode test',
|
|
56
|
+
'$ fcode test [process-slug]',
|
|
57
|
+
'$ fcode test --logLevel DEBUG [process-slug]',
|
|
58
|
+
];
|
|
59
|
+
Test.flags = {
|
|
60
|
+
logLevel: core_1.Flags.string({
|
|
61
|
+
char: 'l',
|
|
62
|
+
description: 'Log level for process execution during tests',
|
|
63
|
+
default: 'ERROR',
|
|
64
|
+
options: ['DEBUG', 'INFO', 'WARNING', 'ERROR'],
|
|
65
|
+
}),
|
|
66
|
+
jsonLogs: core_1.Flags.boolean({
|
|
67
|
+
char: 'j',
|
|
68
|
+
description: 'Output process logs as newline-delimited JSON (NDJSON)',
|
|
69
|
+
default: false,
|
|
70
|
+
}),
|
|
71
|
+
};
|
|
72
|
+
exports.default = Test;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import VariablesCommand from '../../core/commands/variables-command';
|
|
2
|
+
export default class VariablesAdd extends VariablesCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
resourceSlug: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
sensitive: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const variables_command_1 = require("../../core/commands/variables-command");
|
|
5
|
+
const types_1 = require("../../core/types");
|
|
6
|
+
class VariablesAdd extends variables_command_1.default {
|
|
7
|
+
async run() {
|
|
8
|
+
const { flags: { sensitive }, } = await this.parse(VariablesAdd);
|
|
9
|
+
await super.addResources({ variableSensitive: sensitive });
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
VariablesAdd.description = 'Keeps track of a new local variables';
|
|
13
|
+
VariablesAdd.examples = ['$ fcode variables:add'];
|
|
14
|
+
VariablesAdd.args = types_1.ResourceSlugArg;
|
|
15
|
+
VariablesAdd.flags = {
|
|
16
|
+
sensitive: core_1.Flags.boolean({
|
|
17
|
+
char: 's',
|
|
18
|
+
description: 'Add variable as sensitive',
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
exports.default = VariablesAdd;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import VariablesCommand from '../../core/commands/variables-command';
|
|
2
|
+
export default class VariablesPull extends VariablesCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
resourceSlug: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const variables_command_1 = require("../../core/commands/variables-command");
|
|
4
|
+
const types_1 = require("../../core/types");
|
|
5
|
+
class VariablesPull extends variables_command_1.default {
|
|
6
|
+
async run() {
|
|
7
|
+
await super.pullResources();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
VariablesPull.description = 'Fetch all variables from cloud and save them locally';
|
|
11
|
+
VariablesPull.examples = ['$ fcode variables:pull'];
|
|
12
|
+
VariablesPull.args = types_1.ResourceSlugArg;
|
|
13
|
+
VariablesPull.flags = types_1.ForceFlag;
|
|
14
|
+
exports.default = VariablesPull;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import VariablesCommand from '../../core/commands/variables-command';
|
|
2
|
+
export default class VariablesPush extends VariablesCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
resourceSlug: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const variables_command_1 = require("../../core/commands/variables-command");
|
|
4
|
+
const types_1 = require("../../core/types");
|
|
5
|
+
class VariablesPush extends variables_command_1.default {
|
|
6
|
+
async run() {
|
|
7
|
+
await super.pushResources();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
VariablesPush.description = 'Create cloud variables from local ones';
|
|
11
|
+
VariablesPush.examples = ['$ fcode variables:push'];
|
|
12
|
+
VariablesPush.args = types_1.ResourceSlugArg;
|
|
13
|
+
VariablesPush.flags = types_1.ForceFlag;
|
|
14
|
+
exports.default = VariablesPush;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import VariablesCommand from '../../core/commands/variables-command';
|
|
2
|
+
export default class VariablesRemove extends VariablesCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
resourceSlug: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const color_1 = require("@oclif/color");
|
|
4
|
+
const variables_command_1 = require("../../core/commands/variables-command");
|
|
5
|
+
const types_1 = require("../../core/types");
|
|
6
|
+
const cli_1 = require("../../utils/cli");
|
|
7
|
+
class VariablesRemove extends variables_command_1.default {
|
|
8
|
+
async run() {
|
|
9
|
+
if (!this.resourceSlug) {
|
|
10
|
+
cli_1.default.log(color_1.default.red(`You must specify a variable slug`));
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
await super.removeResource(this.resourceSlug);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
VariablesRemove.description = 'Remove track of local variables';
|
|
17
|
+
VariablesRemove.examples = ['$ fcode variables:remove variable-slug'];
|
|
18
|
+
VariablesRemove.args = types_1.ResourceSlugArg;
|
|
19
|
+
exports.default = VariablesRemove;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import VariablesCommand from '../../core/commands/variables-command';
|
|
2
|
+
export default class VariablesReset extends VariablesCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
resourceSlug: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const variables_command_1 = require("../../core/commands/variables-command");
|
|
4
|
+
const types_1 = require("../../core/types");
|
|
5
|
+
class VariablesReset extends variables_command_1.default {
|
|
6
|
+
async run() {
|
|
7
|
+
await super.resetResources();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
VariablesReset.description = 'Reset variables with contents from current remote';
|
|
11
|
+
VariablesReset.examples = ['$ fcode variables:reset'];
|
|
12
|
+
VariablesReset.args = types_1.ResourceSlugArg;
|
|
13
|
+
exports.default = VariablesReset;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type MergedResource } from '../../core/types';
|
|
2
|
+
import VariablesCommand from '../../core/commands/variables-command';
|
|
3
|
+
export default class VariablesStatus extends VariablesCommand {
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static args: {
|
|
7
|
+
resourceSlug: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
8
|
+
};
|
|
9
|
+
resourcesTableLog(resources: Array<MergedResource>): Promise<void>;
|
|
10
|
+
private logVariableWarnings;
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cli_1 = require("../../utils/cli");
|
|
4
|
+
const types_1 = require("../../core/types");
|
|
5
|
+
const variables_command_1 = require("../../core/commands/variables-command");
|
|
6
|
+
const colorize_resource_1 = require("../../utils/colorize-resource");
|
|
7
|
+
const variable_warnings_1 = require("../../utils/variable-warnings");
|
|
8
|
+
const global_1 = require("../../config/global");
|
|
9
|
+
const settings_1 = require("../../config/settings");
|
|
10
|
+
class VariablesStatus extends variables_command_1.default {
|
|
11
|
+
async resourcesTableLog(resources) {
|
|
12
|
+
const globalConfig = new global_1.default();
|
|
13
|
+
const localVariablesFileName = await globalConfig.getSetting(settings_1.SettingKeys.LOCAL_VARIABLES_FILE_NAME);
|
|
14
|
+
cli_1.cli.table(resources, {
|
|
15
|
+
key: {
|
|
16
|
+
get({ key, status }) {
|
|
17
|
+
return (0, colorize_resource_1.colorizeByStatus)(key, status);
|
|
18
|
+
},
|
|
19
|
+
header: 'key',
|
|
20
|
+
},
|
|
21
|
+
status: {
|
|
22
|
+
get({ status }) {
|
|
23
|
+
return (0, colorize_resource_1.colorizeByStatus)(status, status);
|
|
24
|
+
},
|
|
25
|
+
header: 'status',
|
|
26
|
+
},
|
|
27
|
+
value: {
|
|
28
|
+
get({ isSensitive, value, status, overriddenLocally }) {
|
|
29
|
+
if (!isSensitive) {
|
|
30
|
+
return (0, colorize_resource_1.colorizeByStatus)(value || '', status);
|
|
31
|
+
}
|
|
32
|
+
return (0, colorize_resource_1.colorizeByStatus)(overriddenLocally ? '🤐' : `🤐 (use ${localVariablesFileName} to override)`, status);
|
|
33
|
+
},
|
|
34
|
+
header: 'value',
|
|
35
|
+
},
|
|
36
|
+
localOverride: {
|
|
37
|
+
get({ overriddenLocally }) {
|
|
38
|
+
return overriddenLocally ? `↩︎ ${localVariablesFileName}` : '';
|
|
39
|
+
},
|
|
40
|
+
header: 'local override',
|
|
41
|
+
},
|
|
42
|
+
}, { sort: 'key' });
|
|
43
|
+
this.logVariableWarnings(resources, localVariablesFileName);
|
|
44
|
+
}
|
|
45
|
+
logVariableWarnings(resources, localVariablesFileName) {
|
|
46
|
+
const sensitivityChanged = resources.filter((resource) => resource.status === types_1.ResourceStatus.SENSITIVITY_CHANGED);
|
|
47
|
+
(0, variable_warnings_1.warnSensitivityChanged)(sensitivityChanged.map((resource) => resource.slug));
|
|
48
|
+
const tampered = resources.filter((resource) => (0, variable_warnings_1.isTamperedSensitive)(resource));
|
|
49
|
+
(0, variable_warnings_1.warnTamperedSensitive)(tampered.map((resource) => resource.slug), localVariablesFileName);
|
|
50
|
+
}
|
|
51
|
+
async run() {
|
|
52
|
+
await this.resourcesLog();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
VariablesStatus.description = 'List all variables status';
|
|
56
|
+
VariablesStatus.examples = ['$ fcode variables:status'];
|
|
57
|
+
VariablesStatus.args = types_1.ResourceSlugArg;
|
|
58
|
+
exports.default = VariablesStatus;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AuthInfo, TeamOrigin, UserInfo } from '../core/types';
|
|
2
|
+
import Config from './index';
|
|
3
|
+
export declare const FCODE_CLOUD_URL: string;
|
|
4
|
+
export declare function parseTeamOrigin(slug: string): TeamOrigin;
|
|
5
|
+
declare class GlobalConfig extends Config {
|
|
6
|
+
constructor();
|
|
7
|
+
clearAuthInfo(url: string): Promise<void>;
|
|
8
|
+
getAuthInfo(url: string): Promise<AuthInfo>;
|
|
9
|
+
getUserInfo(url: string): Promise<UserInfo>;
|
|
10
|
+
setAuthInfo(url: string, authInfo?: AuthInfo): Promise<void>;
|
|
11
|
+
getSetting(key: string): Promise<string>;
|
|
12
|
+
setSetting(key: string, value: string): Promise<void>;
|
|
13
|
+
removeSetting(key: string): Promise<boolean>;
|
|
14
|
+
}
|
|
15
|
+
export default GlobalConfig;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FCODE_CLOUD_URL = void 0;
|
|
4
|
+
exports.parseTeamOrigin = parseTeamOrigin;
|
|
5
|
+
const fs = require("fs-extra");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
const errors_1 = require("../core/errors");
|
|
8
|
+
const index_1 = require("./index");
|
|
9
|
+
const settings_1 = require("./settings");
|
|
10
|
+
exports.FCODE_CLOUD_URL = process.env.FCODE_CLOUD_URL || 'https://code.factorial.dev/platform';
|
|
11
|
+
function parseTeamOrigin(slug) {
|
|
12
|
+
if (!slug) {
|
|
13
|
+
return { url: exports.FCODE_CLOUD_URL, slug: '' };
|
|
14
|
+
}
|
|
15
|
+
let url;
|
|
16
|
+
try {
|
|
17
|
+
const { origin } = new URL(slug);
|
|
18
|
+
slug = slug.replaceAll(origin + '/', '');
|
|
19
|
+
url = origin;
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
url = exports.FCODE_CLOUD_URL;
|
|
23
|
+
}
|
|
24
|
+
return { url, slug };
|
|
25
|
+
}
|
|
26
|
+
class GlobalConfig extends index_1.default {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(path.join(index_1.default.FCODE_CONFIG_PATH));
|
|
29
|
+
}
|
|
30
|
+
async clearAuthInfo(url) {
|
|
31
|
+
await this.setAuthInfo(url);
|
|
32
|
+
}
|
|
33
|
+
async getAuthInfo(url) {
|
|
34
|
+
if (await this.get('auth')) {
|
|
35
|
+
// TODO: Remove this legacy auth config
|
|
36
|
+
fs.removeSync(this.configPath);
|
|
37
|
+
}
|
|
38
|
+
const auth = await this.get(url);
|
|
39
|
+
if (auth) {
|
|
40
|
+
return auth;
|
|
41
|
+
}
|
|
42
|
+
throw new errors_1.NotAuthenticated(url);
|
|
43
|
+
}
|
|
44
|
+
async getUserInfo(url) {
|
|
45
|
+
const authInfo = await this.getAuthInfo(url);
|
|
46
|
+
if (authInfo) {
|
|
47
|
+
return authInfo.userInfo;
|
|
48
|
+
}
|
|
49
|
+
throw new errors_1.NotAuthenticated(url);
|
|
50
|
+
}
|
|
51
|
+
async setAuthInfo(url, authInfo) {
|
|
52
|
+
await this.set(url, authInfo);
|
|
53
|
+
}
|
|
54
|
+
async getSetting(key) {
|
|
55
|
+
const settings = (await this.get('settings')) || {};
|
|
56
|
+
if (settings[key] !== undefined) {
|
|
57
|
+
return settings[key];
|
|
58
|
+
}
|
|
59
|
+
const defaultValue = (0, settings_1.getSettingDefault)(key);
|
|
60
|
+
return defaultValue !== undefined ? defaultValue : '';
|
|
61
|
+
}
|
|
62
|
+
async setSetting(key, value) {
|
|
63
|
+
const currentSettings = (await this.get('settings')) || {};
|
|
64
|
+
const updatedSettings = { ...currentSettings, [key]: value };
|
|
65
|
+
await this.set('settings', updatedSettings);
|
|
66
|
+
}
|
|
67
|
+
async removeSetting(key) {
|
|
68
|
+
const currentSettings = (await this.get('settings')) || {};
|
|
69
|
+
if (!(key in currentSettings)) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
const { [key]: removed, ...updatedSettings } = currentSettings;
|
|
73
|
+
await this.set('settings', updatedSettings);
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.default = GlobalConfig;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Config as ConfigType } from '../core/types';
|
|
2
|
+
declare class Config {
|
|
3
|
+
static FCODE_CONFIG_PATH: string;
|
|
4
|
+
static FCODE_CONFIG_FILENAME: string;
|
|
5
|
+
static FCODE_DEPENDENCIES_FOLDER: string;
|
|
6
|
+
protected configPath: string;
|
|
7
|
+
protected configDir: string;
|
|
8
|
+
constructor(configDir: string, filename?: string);
|
|
9
|
+
static initConfig(configPath: string, config: ConfigType): void;
|
|
10
|
+
get<T>(key: string): Promise<T | undefined>;
|
|
11
|
+
getAll(): Promise<ConfigType>;
|
|
12
|
+
set<T>(key: string, value: T): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export default Config;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const os = require("node:os");
|
|
4
|
+
const fs = require("fs-extra");
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
const errors_1 = require("../core/errors");
|
|
7
|
+
class Config {
|
|
8
|
+
constructor(configDir, filename = Config.FCODE_CONFIG_FILENAME) {
|
|
9
|
+
this.configDir = configDir;
|
|
10
|
+
this.configPath = path.join(configDir, filename);
|
|
11
|
+
if (!fs.pathExistsSync(this.configPath)) {
|
|
12
|
+
fs.mkdirpSync(path.dirname(this.configPath));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
static initConfig(configPath, config) {
|
|
16
|
+
fs.writeJsonSync(configPath, config, { spaces: 2 });
|
|
17
|
+
}
|
|
18
|
+
async get(key) {
|
|
19
|
+
if (fs.pathExistsSync(this.configPath)) {
|
|
20
|
+
const { [key]: value } = await this.getAll();
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
async getAll() {
|
|
26
|
+
if (fs.pathExistsSync(this.configPath)) {
|
|
27
|
+
return fs.readJsonSync(this.configPath);
|
|
28
|
+
}
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
async set(key, value) {
|
|
32
|
+
const config = await this.getAll();
|
|
33
|
+
try {
|
|
34
|
+
fs.writeJsonSync(this.configPath, { ...config, [key]: value }, { spaces: 2 });
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
throw new errors_1.NotFcodeWorkspace();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
Config.FCODE_CONFIG_PATH = path.join(process.env.FCODE_CONFIG_PATH || os.homedir(), '.fcode');
|
|
42
|
+
Config.FCODE_CONFIG_FILENAME = 'fcode.json';
|
|
43
|
+
Config.FCODE_DEPENDENCIES_FOLDER = 'dependencies';
|
|
44
|
+
exports.default = Config;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TeamMetadata } from '../core/types';
|
|
2
|
+
export default class RemoteConfig {
|
|
3
|
+
static FCODE_REMOTE_CONFIG_FILENAME: string;
|
|
4
|
+
private configPath;
|
|
5
|
+
private remote;
|
|
6
|
+
hash: string;
|
|
7
|
+
private static configPath;
|
|
8
|
+
static save(hash: any, team: TeamMetadata, configPath?: string): void;
|
|
9
|
+
static get(hash: string, configPath?: string): TeamMetadata | undefined;
|
|
10
|
+
private static sortDeeply;
|
|
11
|
+
private static sort;
|
|
12
|
+
constructor(remote: string, configPath?: string);
|
|
13
|
+
init(): void;
|
|
14
|
+
private createDir;
|
|
15
|
+
}
|