@factorialco/fcode-cli 2.4.0 → 3.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 +332 -118
- 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/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 +2 -2
- 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/settings/pull.d.ts +11 -0
- package/dist/commands/settings/pull.js +41 -0
- package/dist/commands/{team → settings}/push.d.ts +4 -4
- package/dist/commands/{team → settings}/push.js +39 -39
- 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 -1
- package/dist/commands/{team → settings}/versions/create.js +13 -10
- 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 +90 -0
- package/dist/commands/team/pull.d.ts +3 -7
- package/dist/commands/team/pull.js +24 -30
- package/dist/commands/team/status.d.ts +3 -4
- package/dist/commands/team/status.js +38 -33
- 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 +64 -0
- package/dist/config/dev-team.js +76 -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/executors/javascript-execution-task.js +25 -3
- package/dist/core/types.d.ts +30 -7
- package/dist/core/types.js +38 -10
- package/dist/repositories/process.d.ts +8 -2
- package/dist/repositories/process.js +28 -18
- package/dist/repositories/programming-language-manifest.d.ts +15 -1
- package/dist/repositories/programming-language-manifest.js +45 -1
- package/dist/repositories/settings.d.ts +52 -0
- package/dist/repositories/settings.js +214 -0
- package/dist/runtime/libs/python/fcode/context.py +29 -2
- package/dist/services/dashboard-client.d.ts +43 -0
- package/dist/services/dashboard-client.js +108 -0
- package/dist/services/dev-team-service.d.ts +55 -0
- package/dist/services/dev-team-service.js +221 -0
- package/dist/services/fcode-graphql-client.d.ts +16 -2
- package/dist/services/fcode-graphql-client.js +56 -7
- package/dist/services/locale-resolver.d.ts +16 -5
- package/dist/services/locale-resolver.js +60 -12
- 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 +4 -4
- package/dist/services/team-versioning.js +4 -4
- 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/slugify.d.ts +17 -0
- package/dist/utils/slugify.js +41 -0
- package/oclif.manifest.json +428 -116
- package/package.json +12 -7
- package/dist/repositories/team.d.ts +0 -41
- package/dist/repositories/team.js +0 -170
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@factorialco/fcode-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"packageManager": "pnpm@11.7.0",
|
|
5
5
|
"description": "Factorial Code Command Line Interface",
|
|
6
6
|
"homepage": "https://code.factorialhr.com/docs/cli/",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@oclif/core": "^4.0.37",
|
|
34
34
|
"@oclif/plugin-help": "^6.2.36",
|
|
35
35
|
"chalk": "^4.1.2",
|
|
36
|
+
"diff": "^5.2.0",
|
|
36
37
|
"dotenv": "^16.4.7",
|
|
37
38
|
"fs-extra": "^11.2.0",
|
|
38
39
|
"lodash": "^4.17.21",
|
|
@@ -53,6 +54,7 @@
|
|
|
53
54
|
"@oclif/test": "^4.1.15",
|
|
54
55
|
"@types/chai": "^4.3.20",
|
|
55
56
|
"@types/cli-table": "^0.3.4",
|
|
57
|
+
"@types/diff": "^5.2.3",
|
|
56
58
|
"@types/fs-extra": "^11.0.4",
|
|
57
59
|
"@types/lodash": "^4.17.21",
|
|
58
60
|
"@types/mocha": "^10.0.10",
|
|
@@ -103,8 +105,8 @@
|
|
|
103
105
|
"variables": {
|
|
104
106
|
"description": "Manage variables resources"
|
|
105
107
|
},
|
|
106
|
-
"
|
|
107
|
-
"description": "Manage CLI
|
|
108
|
+
"config": {
|
|
109
|
+
"description": "Manage CLI configuration"
|
|
108
110
|
},
|
|
109
111
|
"dependencies": {
|
|
110
112
|
"description": "Manage dependencies resources"
|
|
@@ -112,16 +114,19 @@
|
|
|
112
114
|
"remote": {
|
|
113
115
|
"description": "Manage remote team workspaces"
|
|
114
116
|
},
|
|
115
|
-
"
|
|
116
|
-
"description": "Manage
|
|
117
|
+
"settings": {
|
|
118
|
+
"description": "Manage workspace settings (timezone, error handler, inheritance) and workspace versions",
|
|
117
119
|
"subtopics": {
|
|
118
120
|
"versions": {
|
|
119
|
-
"description": "Manage
|
|
121
|
+
"description": "Manage workspace versions across every owned process and module"
|
|
120
122
|
},
|
|
121
123
|
"aliases": {
|
|
122
|
-
"description": "Manage
|
|
124
|
+
"description": "Manage workspace version aliases (e.g. production)"
|
|
123
125
|
}
|
|
124
126
|
}
|
|
127
|
+
},
|
|
128
|
+
"team": {
|
|
129
|
+
"description": "Work with every App your development team owns, in one folder"
|
|
125
130
|
}
|
|
126
131
|
}
|
|
127
132
|
},
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { RawTeamSettings, Team, TeamVersion, TeamVersionAlias } from '../core/types';
|
|
2
|
-
import WorkspaceConfig from '../config/workspace';
|
|
3
|
-
/**
|
|
4
|
-
* Reads/writes the singleton team.json (timezone, error handler, inheritance, webhook auth) at the
|
|
5
|
-
* workspace root. Unlike collection resources this is not a ResourceRepositoryBase:
|
|
6
|
-
* there is exactly one team, so there is no slug-keyed collection to manage.
|
|
7
|
-
*
|
|
8
|
-
* team.json references the error-handler process by slug for portability; the cloud
|
|
9
|
-
* references it by id, so this repository resolves slug<->id against the tracked
|
|
10
|
-
* process metadata in .fcode/.
|
|
11
|
-
*/
|
|
12
|
-
export default class TeamRepository {
|
|
13
|
-
protected workspaceConfig: WorkspaceConfig;
|
|
14
|
-
exists(): boolean;
|
|
15
|
-
find(): Promise<Team>;
|
|
16
|
-
save(team: Team): void;
|
|
17
|
-
/** Builds a Team from the cloud's raw settings, resolving the error-handler id to a slug. */
|
|
18
|
-
fromRaw(raw: RawTeamSettings): Promise<Team>;
|
|
19
|
-
/**
|
|
20
|
-
* Writes the cloud's team versions and aliases into the Team as the team.json versioning
|
|
21
|
-
* fields (sorted for stable git diffs). Cloud entries always carry a createdAt; only
|
|
22
|
-
* hand-added local entries lack one, and those never pass through here.
|
|
23
|
-
*/
|
|
24
|
-
applyCloudVersioning(team: Team, versions: TeamVersion[], aliases: TeamVersionAlias[]): void;
|
|
25
|
-
resolveSlugToId(processSlug: string): Promise<string>;
|
|
26
|
-
resolveIdToSlug(processId: string): Promise<string>;
|
|
27
|
-
private parseErrorHandler;
|
|
28
|
-
/**
|
|
29
|
-
* team.json is hand-edited to declare versions, so entries without a tag are dropped and a
|
|
30
|
-
* duplicated tag keeps its first entry (a tag names one immutable snapshot).
|
|
31
|
-
*/
|
|
32
|
-
private parseVersions;
|
|
33
|
-
/**
|
|
34
|
-
* An alias is a name->tag pointer; entries missing either half are dropped and a duplicated
|
|
35
|
-
* name keeps its first entry.
|
|
36
|
-
*/
|
|
37
|
-
private parseAliases;
|
|
38
|
-
/** A configuration without a variable key is meaningless, so it is read as absent. */
|
|
39
|
-
private parseWebhookAuth;
|
|
40
|
-
private toFile;
|
|
41
|
-
}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fs = require("fs-extra");
|
|
4
|
-
const types_1 = require("../core/types");
|
|
5
|
-
const workspace_1 = require("../config/workspace");
|
|
6
|
-
const file_utils_1 = require("../utils/file-utils");
|
|
7
|
-
const TEAM_FILENAME = 'team.json';
|
|
8
|
-
/**
|
|
9
|
-
* Reads/writes the singleton team.json (timezone, error handler, inheritance, webhook auth) at the
|
|
10
|
-
* workspace root. Unlike collection resources this is not a ResourceRepositoryBase:
|
|
11
|
-
* there is exactly one team, so there is no slug-keyed collection to manage.
|
|
12
|
-
*
|
|
13
|
-
* team.json references the error-handler process by slug for portability; the cloud
|
|
14
|
-
* references it by id, so this repository resolves slug<->id against the tracked
|
|
15
|
-
* process metadata in .fcode/.
|
|
16
|
-
*/
|
|
17
|
-
class TeamRepository {
|
|
18
|
-
constructor() {
|
|
19
|
-
this.workspaceConfig = new workspace_1.default();
|
|
20
|
-
}
|
|
21
|
-
exists() {
|
|
22
|
-
return fs.pathExistsSync(TEAM_FILENAME);
|
|
23
|
-
}
|
|
24
|
-
async find() {
|
|
25
|
-
const slug = await this.workspaceConfig.getActiveTeamSlug();
|
|
26
|
-
let raw = {};
|
|
27
|
-
try {
|
|
28
|
-
raw = fs.readJsonSync(TEAM_FILENAME) || {};
|
|
29
|
-
}
|
|
30
|
-
catch { }
|
|
31
|
-
const parentTeamSlugs = Array.isArray(raw.parentTeamSlugs) ? raw.parentTeamSlugs : [];
|
|
32
|
-
const team = new types_1.Team(slug, parentTeamSlugs, raw.zoneId, this.parseErrorHandler(raw.errorHandlerConfig), this.parseWebhookAuth(raw.webhookAuth), typeof raw.primaryLocale === 'string' && raw.primaryLocale.length > 0 ? raw.primaryLocale : undefined);
|
|
33
|
-
if (Array.isArray(raw.versions)) {
|
|
34
|
-
team.versions = this.parseVersions(raw.versions);
|
|
35
|
-
}
|
|
36
|
-
if (Array.isArray(raw.aliases)) {
|
|
37
|
-
team.aliases = this.parseAliases(raw.aliases);
|
|
38
|
-
}
|
|
39
|
-
return team;
|
|
40
|
-
}
|
|
41
|
-
save(team) {
|
|
42
|
-
(0, file_utils_1.outputFileSyncIfChanged)(TEAM_FILENAME, JSON.stringify(this.toFile(team), null, 2));
|
|
43
|
-
}
|
|
44
|
-
/** Builds a Team from the cloud's raw settings, resolving the error-handler id to a slug. */
|
|
45
|
-
async fromRaw(raw) {
|
|
46
|
-
let errorHandlerConfig;
|
|
47
|
-
if (raw.errorHandlerConfig?.processId) {
|
|
48
|
-
errorHandlerConfig = {
|
|
49
|
-
processSlug: await this.resolveIdToSlug(raw.errorHandlerConfig.processId),
|
|
50
|
-
tag: raw.errorHandlerConfig.tag ?? null,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
return new types_1.Team(raw.slug, raw.parentTeamSlugs ?? [], raw.zoneId, errorHandlerConfig, this.parseWebhookAuth(raw.webhookAuth), raw.primaryLocale ?? undefined);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Writes the cloud's team versions and aliases into the Team as the team.json versioning
|
|
57
|
-
* fields (sorted for stable git diffs). Cloud entries always carry a createdAt; only
|
|
58
|
-
* hand-added local entries lack one, and those never pass through here.
|
|
59
|
-
*/
|
|
60
|
-
applyCloudVersioning(team, versions, aliases) {
|
|
61
|
-
team.versions = versions
|
|
62
|
-
.map((version) => {
|
|
63
|
-
const entry = { tag: version.tag, createdAt: version.createdAt };
|
|
64
|
-
if (version.comment) {
|
|
65
|
-
entry.comment = version.comment;
|
|
66
|
-
}
|
|
67
|
-
return entry;
|
|
68
|
-
})
|
|
69
|
-
.sort((a, b) => (a.createdAt ?? '').localeCompare(b.createdAt ?? ''));
|
|
70
|
-
team.aliases = aliases
|
|
71
|
-
.map((alias) => ({ name: alias.name, tag: alias.tag }))
|
|
72
|
-
.sort((a, b) => a.name.localeCompare(b.name));
|
|
73
|
-
}
|
|
74
|
-
async resolveSlugToId(processSlug) {
|
|
75
|
-
const { processes } = await this.workspaceConfig.getActiveTeam();
|
|
76
|
-
return processes[processSlug]?.id ?? processSlug;
|
|
77
|
-
}
|
|
78
|
-
async resolveIdToSlug(processId) {
|
|
79
|
-
const { processes } = await this.workspaceConfig.getActiveTeam();
|
|
80
|
-
const match = Object.values(processes).find((process) => process.id === processId);
|
|
81
|
-
return match?.slug ?? processId;
|
|
82
|
-
}
|
|
83
|
-
parseErrorHandler(raw) {
|
|
84
|
-
if (!raw || !raw.processSlug) {
|
|
85
|
-
return undefined;
|
|
86
|
-
}
|
|
87
|
-
return { processSlug: raw.processSlug, tag: raw.tag ?? null };
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* team.json is hand-edited to declare versions, so entries without a tag are dropped and a
|
|
91
|
-
* duplicated tag keeps its first entry (a tag names one immutable snapshot).
|
|
92
|
-
*/
|
|
93
|
-
parseVersions(raw) {
|
|
94
|
-
const versions = [];
|
|
95
|
-
for (const candidate of raw) {
|
|
96
|
-
if (!candidate || typeof candidate.tag !== 'string' || candidate.tag.length === 0) {
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
if (versions.some(({ tag }) => tag === candidate.tag)) {
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
const entry = { tag: candidate.tag };
|
|
103
|
-
if (typeof candidate.comment === 'string' && candidate.comment.length > 0) {
|
|
104
|
-
entry.comment = candidate.comment;
|
|
105
|
-
}
|
|
106
|
-
if (typeof candidate.createdAt === 'string' && candidate.createdAt.length > 0) {
|
|
107
|
-
entry.createdAt = candidate.createdAt;
|
|
108
|
-
}
|
|
109
|
-
versions.push(entry);
|
|
110
|
-
}
|
|
111
|
-
return versions;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* An alias is a name->tag pointer; entries missing either half are dropped and a duplicated
|
|
115
|
-
* name keeps its first entry.
|
|
116
|
-
*/
|
|
117
|
-
parseAliases(raw) {
|
|
118
|
-
const aliases = [];
|
|
119
|
-
for (const candidate of raw) {
|
|
120
|
-
if (!candidate || typeof candidate.name !== 'string' || candidate.name.length === 0) {
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
if (typeof candidate.tag !== 'string' || candidate.tag.length === 0) {
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
if (aliases.some(({ name }) => name === candidate.name)) {
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
aliases.push({ name: candidate.name, tag: candidate.tag });
|
|
130
|
-
}
|
|
131
|
-
return aliases;
|
|
132
|
-
}
|
|
133
|
-
/** A configuration without a variable key is meaningless, so it is read as absent. */
|
|
134
|
-
parseWebhookAuth(raw) {
|
|
135
|
-
if (!raw || typeof raw.variableKey !== 'string' || raw.variableKey.length === 0) {
|
|
136
|
-
return undefined;
|
|
137
|
-
}
|
|
138
|
-
const webhookAuth = { variableKey: raw.variableKey };
|
|
139
|
-
// The default header is left out so a pull writes the minimal form.
|
|
140
|
-
if (typeof raw.headerName === 'string' && raw.headerName.length > 0 && raw.headerName !== types_1.DEFAULT_WEBHOOK_AUTH_HEADER) {
|
|
141
|
-
webhookAuth.headerName = raw.headerName;
|
|
142
|
-
}
|
|
143
|
-
return webhookAuth;
|
|
144
|
-
}
|
|
145
|
-
toFile(team) {
|
|
146
|
-
const file = { parentTeamSlugs: team.parentTeamSlugs ?? [] };
|
|
147
|
-
if (team.zoneId !== undefined) {
|
|
148
|
-
file.zoneId = team.zoneId;
|
|
149
|
-
}
|
|
150
|
-
if (team.errorHandlerConfig !== undefined) {
|
|
151
|
-
file.errorHandlerConfig = team.errorHandlerConfig;
|
|
152
|
-
}
|
|
153
|
-
// Last, so adding webhook auth to an existing team.json is a purely additive diff.
|
|
154
|
-
if (team.webhookAuth !== undefined) {
|
|
155
|
-
file.webhookAuth = team.webhookAuth;
|
|
156
|
-
}
|
|
157
|
-
if (team.primaryLocale !== undefined) {
|
|
158
|
-
file.primaryLocale = team.primaryLocale;
|
|
159
|
-
}
|
|
160
|
-
// Global versioning fields, appended after the scalar settings.
|
|
161
|
-
if (team.versions !== undefined) {
|
|
162
|
-
file.versions = team.versions;
|
|
163
|
-
}
|
|
164
|
-
if (team.aliases !== undefined) {
|
|
165
|
-
file.aliases = team.aliases;
|
|
166
|
-
}
|
|
167
|
-
return file;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
exports.default = TeamRepository;
|