@factorialco/fcode-cli 2.3.0 → 3.0.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 +334 -117
- package/dist/commands/clone.d.ts +0 -12
- package/dist/commands/clone.js +22 -135
- package/dist/commands/{settings → config}/get.d.ts +1 -1
- package/dist/commands/{settings → config}/get.js +7 -7
- package/dist/commands/{settings → config}/remove.d.ts +1 -1
- package/dist/commands/{settings → config}/remove.js +6 -6
- package/dist/commands/{settings → config}/set.d.ts +1 -1
- package/dist/commands/{settings → config}/set.js +8 -8
- package/dist/commands/dependencies/diff.d.ts +9 -0
- package/dist/commands/dependencies/diff.js +15 -0
- package/dist/commands/dependencies/pull.d.ts +9 -0
- package/dist/commands/dependencies/pull.js +44 -1
- package/dist/commands/dependencies/status.d.ts +11 -0
- package/dist/commands/dependencies/status.js +43 -0
- package/dist/commands/diff.d.ts +12 -0
- package/dist/commands/diff.js +48 -0
- package/dist/commands/http.d.ts +1 -1
- package/dist/commands/http.js +7 -7
- package/dist/commands/i18n/diff.d.ts +9 -0
- package/dist/commands/i18n/diff.js +15 -0
- package/dist/commands/i18n/status.d.ts +3 -0
- package/dist/commands/i18n/status.js +1 -0
- package/dist/commands/modules/diff.d.ts +9 -0
- package/dist/commands/modules/diff.js +15 -0
- package/dist/commands/modules/status.d.ts +3 -0
- package/dist/commands/modules/status.js +1 -0
- package/dist/commands/processes/diff.d.ts +9 -0
- package/dist/commands/processes/diff.js +15 -0
- package/dist/commands/processes/status.d.ts +3 -0
- package/dist/commands/processes/status.js +1 -0
- package/dist/commands/pull.js +3 -3
- package/dist/commands/push.js +2 -2
- package/dist/commands/{team → settings}/aliases/delete.d.ts +1 -1
- package/dist/commands/{team → settings}/aliases/delete.js +6 -6
- package/dist/commands/{team → settings}/aliases/list.d.ts +1 -1
- package/dist/commands/{team → settings}/aliases/list.js +8 -8
- package/dist/commands/{team → settings}/aliases/set.d.ts +1 -1
- package/dist/commands/{team → settings}/aliases/set.js +8 -8
- package/dist/commands/settings/diff.d.ts +8 -0
- package/dist/commands/settings/diff.js +39 -0
- package/dist/commands/{team/push.d.ts → settings/pull.d.ts} +3 -3
- package/dist/commands/settings/pull.js +41 -0
- package/dist/commands/settings/push.d.ts +13 -0
- package/dist/commands/settings/push.js +103 -0
- package/dist/commands/settings/status.d.ts +8 -0
- package/dist/commands/settings/status.js +46 -0
- package/dist/commands/{team → settings}/versions/create.d.ts +1 -2
- package/dist/commands/settings/versions/create.js +36 -0
- package/dist/commands/{team → settings}/versions/delete.d.ts +1 -1
- package/dist/commands/{team → settings}/versions/delete.js +10 -10
- package/dist/commands/{team → settings}/versions/list.d.ts +1 -1
- package/dist/commands/{team → settings}/versions/list.js +8 -8
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.js +10 -7
- package/dist/commands/team/clone.d.ts +14 -0
- package/dist/commands/team/clone.js +91 -0
- package/dist/commands/team/pull.d.ts +3 -4
- package/dist/commands/team/pull.js +25 -19
- package/dist/commands/team/status.d.ts +3 -4
- package/dist/commands/team/status.js +34 -27
- package/dist/commands/variables/diff.d.ts +9 -0
- package/dist/commands/variables/diff.js +15 -0
- package/dist/commands/variables/status.d.ts +3 -0
- package/dist/commands/variables/status.js +1 -0
- package/dist/config/dev-team.d.ts +48 -0
- package/dist/config/dev-team.js +62 -0
- package/dist/config/workspace.d.ts +2 -2
- package/dist/config/workspace.js +4 -2
- package/dist/core/commands/base-command.js +5 -0
- package/dist/core/commands/dependency-command.d.ts +2 -1
- package/dist/core/commands/dependency-command.js +3 -0
- package/dist/core/commands/i18n-command.js +2 -0
- package/dist/core/commands/modules-command.js +2 -0
- package/dist/core/commands/processes-command.js +2 -0
- package/dist/core/commands/resource-command.d.ts +26 -1
- package/dist/core/commands/resource-command.js +100 -3
- package/dist/core/commands/variables-command.d.ts +7 -0
- package/dist/core/commands/variables-command.js +13 -0
- package/dist/core/dependencies/env-dependencies-command.js +6 -3
- package/dist/core/executors/javascript-execution-task.js +36 -5
- package/dist/core/types.d.ts +59 -9
- package/dist/core/types.js +64 -10
- package/dist/core/utils/dependencies.js +4 -1
- package/dist/env.js +1 -1
- package/dist/repositories/process.d.ts +8 -2
- package/dist/repositories/process.js +29 -15
- package/dist/repositories/programming-language-manifest.d.ts +31 -1
- package/dist/repositories/programming-language-manifest.js +96 -2
- package/dist/repositories/settings.d.ts +52 -0
- package/dist/repositories/settings.js +214 -0
- package/dist/runtime/libs/python/fcode/context.py +42 -8
- package/dist/services/dashboard-client.d.ts +31 -0
- package/dist/services/dashboard-client.js +99 -0
- package/dist/services/dev-team-service.d.ts +41 -0
- package/dist/services/dev-team-service.js +162 -0
- package/dist/services/fcode-graphql-client.d.ts +17 -2
- package/dist/services/fcode-graphql-client.js +127 -15
- package/dist/services/locale-resolver.d.ts +17 -1
- package/dist/services/locale-resolver.js +62 -7
- package/dist/services/resource-differ.d.ts +60 -0
- package/dist/services/resource-differ.js +135 -0
- package/dist/services/skills-installer.d.ts +16 -0
- package/dist/services/skills-installer.js +77 -0
- package/dist/services/team-versioning.d.ts +16 -0
- package/dist/services/team-versioning.js +40 -0
- package/dist/services/webhook-auth.js +1 -1
- package/dist/services/workspace-cloner.d.ts +31 -0
- package/dist/services/workspace-cloner.js +95 -0
- package/dist/utils/dev-slug.d.ts +12 -0
- package/dist/utils/dev-slug.js +37 -0
- package/dist/utils/diff.d.ts +19 -0
- package/dist/utils/diff.js +58 -0
- package/dist/utils/gitignore.d.ts +3 -1
- package/dist/utils/gitignore.js +11 -2
- package/dist/utils/slugify.d.ts +17 -0
- package/dist/utils/slugify.js +41 -0
- package/oclif.manifest.json +433 -113
- package/package.json +12 -7
- package/dist/commands/team/push.js +0 -52
- package/dist/commands/team/versions/create.js +0 -42
- package/dist/repositories/team.d.ts +0 -31
- package/dist/repositories/team.js +0 -127
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const DEV_NULL = "/dev/null";
|
|
2
|
+
/**
|
|
3
|
+
* One comparable artifact of a resource, named after the file it is stored in. A side left
|
|
4
|
+
* undefined does not exist there (a process only in the cloud, a module only on disk); an empty
|
|
5
|
+
* string is a file that exists and is empty, which is a different thing and diffs differently.
|
|
6
|
+
*/
|
|
7
|
+
export type PseudoFile = {
|
|
8
|
+
path: string;
|
|
9
|
+
remote?: string;
|
|
10
|
+
local?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const hasDifference: (file: PseudoFile) => boolean;
|
|
13
|
+
/**
|
|
14
|
+
* A unified diff of one pseudo-file, remote as the old side and local as the new one, so the
|
|
15
|
+
* patch reads as what a push would apply to the cloud. Empty when the sides are equal.
|
|
16
|
+
*/
|
|
17
|
+
export declare function renderUnifiedDiff(file: PseudoFile): string;
|
|
18
|
+
/** Colors a rendered patch the way git does. Chalk no-ops when the output is not a TTY. */
|
|
19
|
+
export declare function colorizeDiff(patch: string): string;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasDifference = exports.DEV_NULL = void 0;
|
|
4
|
+
exports.renderUnifiedDiff = renderUnifiedDiff;
|
|
5
|
+
exports.colorizeDiff = colorizeDiff;
|
|
6
|
+
const diff_1 = require("diff");
|
|
7
|
+
const chalk = require("chalk");
|
|
8
|
+
exports.DEV_NULL = '/dev/null';
|
|
9
|
+
const hasDifference = (file) => file.remote !== file.local;
|
|
10
|
+
exports.hasDifference = hasDifference;
|
|
11
|
+
/**
|
|
12
|
+
* A hunk range the way git writes one: the count is left out when it is 1, and an empty range
|
|
13
|
+
* points at the line it would be inserted after, so a whole-file addition reads `-0,0`.
|
|
14
|
+
*/
|
|
15
|
+
function formatRange(start, lines) {
|
|
16
|
+
if (lines === 1) {
|
|
17
|
+
return `${start}`;
|
|
18
|
+
}
|
|
19
|
+
return `${lines === 0 ? start - 1 : start},${lines}`;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A unified diff of one pseudo-file, remote as the old side and local as the new one, so the
|
|
23
|
+
* patch reads as what a push would apply to the cloud. Empty when the sides are equal.
|
|
24
|
+
*/
|
|
25
|
+
function renderUnifiedDiff(file) {
|
|
26
|
+
if (!(0, exports.hasDifference)(file)) {
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
const oldName = file.remote === undefined ? exports.DEV_NULL : `remote/${file.path}`;
|
|
30
|
+
const newName = file.local === undefined ? exports.DEV_NULL : `local/${file.path}`;
|
|
31
|
+
const { hunks } = (0, diff_1.structuredPatch)(oldName, newName, file.remote ?? '', file.local ?? '', undefined, undefined, { context: 3 });
|
|
32
|
+
const lines = [`--- ${oldName}`, `+++ ${newName}`];
|
|
33
|
+
for (const hunk of hunks) {
|
|
34
|
+
lines.push(`@@ -${formatRange(hunk.oldStart, hunk.oldLines)} +${formatRange(hunk.newStart, hunk.newLines)} @@`, ...hunk.lines);
|
|
35
|
+
}
|
|
36
|
+
return lines.join('\n');
|
|
37
|
+
}
|
|
38
|
+
/** Colors a rendered patch the way git does. Chalk no-ops when the output is not a TTY. */
|
|
39
|
+
function colorizeDiff(patch) {
|
|
40
|
+
return patch
|
|
41
|
+
.split('\n')
|
|
42
|
+
.map((line) => {
|
|
43
|
+
if (line.startsWith('---') || line.startsWith('+++')) {
|
|
44
|
+
return chalk.bold(line);
|
|
45
|
+
}
|
|
46
|
+
if (line.startsWith('@@')) {
|
|
47
|
+
return chalk.cyan(line);
|
|
48
|
+
}
|
|
49
|
+
if (line.startsWith('+')) {
|
|
50
|
+
return chalk.green(line);
|
|
51
|
+
}
|
|
52
|
+
if (line.startsWith('-')) {
|
|
53
|
+
return chalk.red(line);
|
|
54
|
+
}
|
|
55
|
+
return line;
|
|
56
|
+
})
|
|
57
|
+
.join('\n');
|
|
58
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const INHERITED_BLOCK_START = "# BEGIN fcode inherited resources (auto-generated, do not edit)";
|
|
2
2
|
export declare const INHERITED_BLOCK_END = "# END fcode inherited resources";
|
|
3
|
+
export declare const INHERITED_DEPENDENCY_FILES: string[];
|
|
3
4
|
/**
|
|
4
5
|
* Rebuilds the managed "inherited resources" block in a .gitignore.
|
|
5
6
|
*
|
|
@@ -14,6 +15,7 @@ export declare function renderGitignoreWithInherited(existing: string, inherited
|
|
|
14
15
|
* parent team and pulled read-only) are not tracked by git. Regenerated from the
|
|
15
16
|
* current workspace metadata, so resources that stop being inherited drop out.
|
|
16
17
|
* Inherited variable values live in one file, which is ignored as soon as the
|
|
17
|
-
* workspace inherits any variable; inherited locales are one file each, like modules
|
|
18
|
+
* workspace inherits any variable; inherited locales are one file each, like modules;
|
|
19
|
+
* inherited dependencies are one file per language, like variables.
|
|
18
20
|
*/
|
|
19
21
|
export declare function syncInheritedGitignore(workspaceDir?: string): Promise<void>;
|
package/dist/utils/gitignore.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.INHERITED_BLOCK_END = exports.INHERITED_BLOCK_START = void 0;
|
|
3
|
+
exports.INHERITED_DEPENDENCY_FILES = exports.INHERITED_BLOCK_END = exports.INHERITED_BLOCK_START = void 0;
|
|
4
4
|
exports.renderGitignoreWithInherited = renderGitignoreWithInherited;
|
|
5
5
|
exports.syncInheritedGitignore = syncInheritedGitignore;
|
|
6
6
|
const path = require("node:path");
|
|
@@ -8,10 +8,14 @@ const fs = require("fs-extra");
|
|
|
8
8
|
const workspace_1 = require("../config/workspace");
|
|
9
9
|
const global_1 = require("../config/global");
|
|
10
10
|
const settings_1 = require("../config/settings");
|
|
11
|
+
const programming_language_manifest_1 = require("../repositories/programming-language-manifest");
|
|
11
12
|
const filenamify_1 = require("./filenamify");
|
|
12
13
|
const file_utils_1 = require("./file-utils");
|
|
13
14
|
exports.INHERITED_BLOCK_START = '# BEGIN fcode inherited resources (auto-generated, do not edit)';
|
|
14
15
|
exports.INHERITED_BLOCK_END = '# END fcode inherited resources';
|
|
16
|
+
// Derived from the repository that writes them, so renaming a file cannot silently stop it being
|
|
17
|
+
// gitignored.
|
|
18
|
+
exports.INHERITED_DEPENDENCY_FILES = Object.values(programming_language_manifest_1.INHERITED_FILE_NAME).map((name) => `${programming_language_manifest_1.DEPENDENCIES_DIR}/${name}`);
|
|
15
19
|
/**
|
|
16
20
|
* Rebuilds the managed "inherited resources" block in a .gitignore.
|
|
17
21
|
*
|
|
@@ -46,7 +50,8 @@ function stripManagedBlock(content) {
|
|
|
46
50
|
* parent team and pulled read-only) are not tracked by git. Regenerated from the
|
|
47
51
|
* current workspace metadata, so resources that stop being inherited drop out.
|
|
48
52
|
* Inherited variable values live in one file, which is ignored as soon as the
|
|
49
|
-
* workspace inherits any variable; inherited locales are one file each, like modules
|
|
53
|
+
* workspace inherits any variable; inherited locales are one file each, like modules;
|
|
54
|
+
* inherited dependencies are one file per language, like variables.
|
|
50
55
|
*/
|
|
51
56
|
async function syncInheritedGitignore(workspaceDir = process.cwd()) {
|
|
52
57
|
const team = await new workspace_1.default(workspaceDir).getActiveTeam();
|
|
@@ -62,6 +67,10 @@ async function syncInheritedGitignore(workspaceDir = process.cwd()) {
|
|
|
62
67
|
...Object.values(team.i18n ?? {})
|
|
63
68
|
.filter((locale) => locale.resolvingTeamSlug)
|
|
64
69
|
.map((locale) => `i18n/${(0, filenamify_1.default)(locale.slug)}.yaml`),
|
|
70
|
+
// Inherited dependencies are one file per language, written only when there is something to
|
|
71
|
+
// inherit — checked on disk because the manifest metadata tracks the workspace's own list, not
|
|
72
|
+
// what its parents contribute.
|
|
73
|
+
...exports.INHERITED_DEPENDENCY_FILES.filter((file) => fs.existsSync(path.join(workspaceDir, file))),
|
|
65
74
|
];
|
|
66
75
|
const gitignorePath = path.join(workspaceDir, '.gitignore');
|
|
67
76
|
const existing = fs.existsSync(gitignorePath) ? fs.readFileSync(gitignorePath, 'utf8') : '';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Folder name for a development team or an App, derived from its display name. Names are free
|
|
3
|
+
* text — accents, punctuation, emoji — while the folder has to be portable and typeable, so
|
|
4
|
+
* everything outside `[a-z0-9-]` collapses into a single dash.
|
|
5
|
+
*/
|
|
6
|
+
export declare function slugify(name: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* `slugify` with a fallback, so a name written entirely in a non-latin script still yields a
|
|
9
|
+
* usable folder instead of an empty one.
|
|
10
|
+
*/
|
|
11
|
+
export declare function slugifyOr(name: string, fallback: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* The first claimant of a slug keeps it; the next ones get `-2`, `-3`… Callers assign folders in a
|
|
14
|
+
* stable order (by app id), so the same team always produces the same layout — and once assigned,
|
|
15
|
+
* the folder is recorded in the team metadata and never derived again.
|
|
16
|
+
*/
|
|
17
|
+
export declare function uniqueSlug(slug: string, taken: Set<string>): string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.slugify = slugify;
|
|
4
|
+
exports.slugifyOr = slugifyOr;
|
|
5
|
+
exports.uniqueSlug = uniqueSlug;
|
|
6
|
+
/**
|
|
7
|
+
* Folder name for a development team or an App, derived from its display name. Names are free
|
|
8
|
+
* text — accents, punctuation, emoji — while the folder has to be portable and typeable, so
|
|
9
|
+
* everything outside `[a-z0-9-]` collapses into a single dash.
|
|
10
|
+
*/
|
|
11
|
+
function slugify(name) {
|
|
12
|
+
return name
|
|
13
|
+
.normalize('NFKD')
|
|
14
|
+
.replaceAll(/[̀-ͯ]/g, '')
|
|
15
|
+
.replaceAll(/[^a-zA-Z\d]+/g, '-')
|
|
16
|
+
.replaceAll(/^-+|-+$/g, '')
|
|
17
|
+
.toLowerCase();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* `slugify` with a fallback, so a name written entirely in a non-latin script still yields a
|
|
21
|
+
* usable folder instead of an empty one.
|
|
22
|
+
*/
|
|
23
|
+
function slugifyOr(name, fallback) {
|
|
24
|
+
const slug = slugify(name);
|
|
25
|
+
return slug.length > 0 ? slug : fallback;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The first claimant of a slug keeps it; the next ones get `-2`, `-3`… Callers assign folders in a
|
|
29
|
+
* stable order (by app id), so the same team always produces the same layout — and once assigned,
|
|
30
|
+
* the folder is recorded in the team metadata and never derived again.
|
|
31
|
+
*/
|
|
32
|
+
function uniqueSlug(slug, taken) {
|
|
33
|
+
if (!taken.has(slug)) {
|
|
34
|
+
return slug;
|
|
35
|
+
}
|
|
36
|
+
let suffix = 2;
|
|
37
|
+
while (taken.has(`${slug}-${suffix}`)) {
|
|
38
|
+
suffix += 1;
|
|
39
|
+
}
|
|
40
|
+
return `${slug}-${suffix}`;
|
|
41
|
+
}
|