trackops 2.0.4 → 2.0.6
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/LICENSE +21 -21
- package/README.md +660 -575
- package/bin/trackops.js +127 -106
- package/lib/cli-format.js +118 -0
- package/lib/config.js +352 -326
- package/lib/control.js +408 -246
- package/lib/env.js +234 -222
- package/lib/i18n.js +5 -4
- package/lib/init.js +390 -282
- package/lib/locale.js +41 -41
- package/lib/opera-bootstrap.js +1066 -880
- package/lib/opera.js +615 -444
- package/lib/preferences.js +74 -74
- package/lib/registry.js +214 -214
- package/lib/release.js +56 -56
- package/lib/runtime-state.js +144 -144
- package/lib/skills.js +114 -89
- package/lib/workspace.js +259 -248
- package/locales/en.json +311 -167
- package/locales/es.json +314 -170
- package/package.json +61 -58
- package/scripts/postinstall-locale.js +21 -21
- package/scripts/skills-marketplace-smoke.js +124 -124
- package/scripts/smoke-tests.js +563 -517
- package/scripts/sync-skill-version.js +21 -21
- package/scripts/validate-skill.js +103 -103
- package/skills/trackops/SKILL.md +126 -122
- package/skills/trackops/agents/openai.yaml +7 -7
- package/skills/trackops/locales/en/SKILL.md +126 -122
- package/skills/trackops/locales/en/references/activation.md +94 -90
- package/skills/trackops/locales/en/references/troubleshooting.md +73 -67
- package/skills/trackops/locales/en/references/workflow.md +55 -32
- package/skills/trackops/references/activation.md +94 -90
- package/skills/trackops/references/troubleshooting.md +73 -67
- package/skills/trackops/references/workflow.md +55 -32
- package/skills/trackops/skill.json +29 -29
- package/templates/hooks/post-checkout +2 -2
- package/templates/hooks/post-commit +2 -2
- package/templates/hooks/post-merge +2 -2
- package/templates/opera/agent.md +28 -27
- package/templates/opera/architecture/dependency-graph.md +24 -24
- package/templates/opera/architecture/runtime-automation.md +24 -24
- package/templates/opera/architecture/runtime-operations.md +34 -34
- package/templates/opera/en/agent.md +22 -21
- package/templates/opera/en/architecture/dependency-graph.md +24 -24
- package/templates/opera/en/architecture/runtime-automation.md +24 -24
- package/templates/opera/en/architecture/runtime-operations.md +34 -34
- package/templates/opera/en/reviews/delivery-audit.md +18 -18
- package/templates/opera/en/reviews/integration-audit.md +18 -18
- package/templates/opera/en/router.md +24 -19
- package/templates/opera/references/autonomy-and-recovery.md +117 -117
- package/templates/opera/references/opera-cycle.md +193 -193
- package/templates/opera/registry.md +28 -28
- package/templates/opera/reviews/delivery-audit.md +18 -18
- package/templates/opera/reviews/integration-audit.md +18 -18
- package/templates/opera/router.md +54 -49
- package/templates/skills/changelog-updater/SKILL.md +69 -69
- package/templates/skills/commiter/SKILL.md +99 -99
- package/templates/skills/opera-contract-auditor/SKILL.md +38 -38
- package/templates/skills/opera-contract-auditor/locales/en/SKILL.md +38 -38
- package/templates/skills/opera-policy-guard/SKILL.md +26 -26
- package/templates/skills/opera-policy-guard/locales/en/SKILL.md +26 -26
- package/templates/skills/opera-skill/SKILL.md +279 -0
- package/templates/skills/opera-skill/locales/en/SKILL.md +279 -0
- package/templates/skills/opera-skill/locales/en/references/phase-dod.md +138 -0
- package/templates/skills/opera-skill/references/phase-dod.md +138 -0
- package/templates/skills/project-starter-skill/SKILL.md +150 -131
- package/templates/skills/project-starter-skill/locales/en/SKILL.md +143 -105
- package/templates/skills/project-starter-skill/references/opera-cycle.md +195 -193
- package/ui/css/base.css +284 -284
- package/ui/css/charts.css +425 -425
- package/ui/css/components.css +1107 -1107
- package/ui/css/onboarding.css +133 -133
- package/ui/css/terminal.css +125 -125
- package/ui/css/timeline.css +58 -58
- package/ui/css/tokens.css +284 -284
- package/ui/favicon.svg +5 -5
- package/ui/index.html +99 -99
- package/ui/js/charts.js +526 -526
- package/ui/js/console-logger.js +172 -172
- package/ui/js/filters.js +247 -247
- package/ui/js/icons.js +129 -129
- package/ui/js/keyboard.js +229 -229
- package/ui/js/router.js +142 -142
- package/ui/js/theme.js +100 -100
- package/ui/js/time-tracker.js +248 -248
- package/ui/js/views/dashboard.js +870 -870
- package/ui/js/views/flash.js +47 -47
- package/ui/js/views/projects.js +745 -745
- package/ui/js/views/scrum.js +476 -476
- package/ui/js/views/settings.js +331 -331
- package/ui/js/views/timeline.js +265 -265
package/lib/env.js
CHANGED
|
@@ -1,244 +1,256 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const config = require("./config");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
6
|
+
const { t, setLocale } = require("./i18n");
|
|
7
|
+
|
|
8
|
+
const SERVICE_ENV_KEYS = {
|
|
9
|
+
OpenAI: ["OPENAI_API_KEY"],
|
|
10
|
+
Anthropic: ["ANTHROPIC_API_KEY"],
|
|
11
|
+
Stripe: ["STRIPE_SECRET_KEY", "STRIPE_WEBHOOK_SECRET"],
|
|
12
|
+
Supabase: ["SUPABASE_URL", "SUPABASE_ANON_KEY", "SUPABASE_SERVICE_ROLE_KEY"],
|
|
13
|
+
PostgreSQL: ["DATABASE_URL"],
|
|
14
|
+
MySQL: ["DATABASE_URL"],
|
|
15
|
+
Redis: ["REDIS_URL"],
|
|
16
|
+
Slack: ["SLACK_BOT_TOKEN", "SLACK_SIGNING_SECRET"],
|
|
17
|
+
"Amazon S3": ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_REGION", "AWS_S3_BUCKET"],
|
|
18
|
+
AWS: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_REGION"],
|
|
19
|
+
"Google Cloud": ["GOOGLE_APPLICATION_CREDENTIALS"],
|
|
20
|
+
Azure: ["AZURE_OPENAI_API_KEY", "AZURE_OPENAI_ENDPOINT"],
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function unique(items) {
|
|
24
|
+
return [...new Set((items || []).map((item) => String(item || "").trim()).filter(Boolean))];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function readText(filePath) {
|
|
28
|
+
return fs.existsSync(filePath) ? fs.readFileSync(filePath, "utf8") : "";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function parseEnv(text) {
|
|
32
|
+
const entries = {};
|
|
33
|
+
const lines = String(text || "").split(/\r?\n/);
|
|
34
|
+
for (const line of lines) {
|
|
35
|
+
if (!line || /^\s*#/.test(line)) continue;
|
|
36
|
+
const match = line.match(/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)\s*$/);
|
|
37
|
+
if (!match) continue;
|
|
38
|
+
entries[match[1]] = match[2] || "";
|
|
39
|
+
}
|
|
40
|
+
return entries;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function parseEnvKeys(text) {
|
|
44
|
+
return unique(Object.keys(parseEnv(text)));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function normalizeEnvironmentMeta(control, context) {
|
|
48
|
+
const envMeta = control.meta?.environment || {};
|
|
49
|
+
return {
|
|
50
|
+
rootEnvFile: envMeta.rootEnvFile || path.relative(context.workspaceRoot, context.env.rootFile).replace(/\\/g, "/"),
|
|
51
|
+
exampleFile: envMeta.exampleFile || path.relative(context.workspaceRoot, context.env.exampleFile).replace(/\\/g, "/"),
|
|
52
|
+
appBridgeFile: envMeta.appBridgeFile || path.relative(context.workspaceRoot, context.env.appBridgeFile).replace(/\\/g, "/"),
|
|
53
|
+
bridgeMode: envMeta.bridgeMode || (context.layout === "split" ? "symlink-or-copy" : "none"),
|
|
54
|
+
requiredKeys: unique(envMeta.requiredKeys),
|
|
55
|
+
optionalKeys: unique(envMeta.optionalKeys),
|
|
56
|
+
lastAuditAt: envMeta.lastAuditAt || null,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function inferRequiredKeys(control, contextOrRoot) {
|
|
61
|
+
const envMeta = control.meta?.environment || {};
|
|
62
|
+
const fromMeta = unique([...(envMeta.requiredKeys || []), ...(envMeta.optionalKeys || [])]);
|
|
63
|
+
const contractServices = readContractServices(contextOrRoot, control);
|
|
64
|
+
const bootstrapServices = unique([
|
|
65
|
+
...(control.meta?.opera?.bootstrap?.discovery?.externalServices || []),
|
|
66
|
+
...(control.meta?.opera?.bootstrap?.externalServices || []),
|
|
67
|
+
]);
|
|
68
|
+
const fromServices = unique(
|
|
69
|
+
(contractServices.length ? contractServices : bootstrapServices)
|
|
70
|
+
.flatMap((service) => SERVICE_ENV_KEYS[service] || []),
|
|
71
|
+
);
|
|
72
|
+
const context = config.ensureContext(contextOrRoot || process.cwd());
|
|
73
|
+
const fromExample = parseEnvKeys(readText(context.env.exampleFile));
|
|
74
|
+
return unique([...fromMeta, ...fromServices, ...fromExample]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function readContractServices(contextOrRoot, control) {
|
|
78
|
+
const context = config.ensureContext(contextOrRoot || process.cwd());
|
|
79
|
+
const contractFile = context.paths.contractFile;
|
|
80
|
+
if (!fs.existsSync(contractFile)) return [];
|
|
81
|
+
try {
|
|
82
|
+
const contract = JSON.parse(fs.readFileSync(contractFile, "utf8"));
|
|
83
|
+
return Array.isArray(contract?.system?.externalServices) ? contract.system.externalServices : [];
|
|
84
|
+
} catch (_error) {
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function ensureFileWithHeader(filePath, lines) {
|
|
90
|
+
if (fs.existsSync(filePath)) return;
|
|
91
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
92
|
+
fs.writeFileSync(filePath, `${lines.join("\n")}\n`, "utf8");
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function appendMissingKeys(filePath, keys, heading) {
|
|
96
|
+
const existing = readText(filePath);
|
|
97
|
+
const parsed = parseEnvKeys(existing);
|
|
98
|
+
const missing = unique(keys).filter((key) => !parsed.includes(key));
|
|
99
|
+
if (!missing.length) return;
|
|
100
|
+
|
|
101
|
+
const chunks = [];
|
|
102
|
+
if (existing.trim()) chunks.push("");
|
|
103
|
+
if (heading) chunks.push(heading);
|
|
104
|
+
missing.forEach((key) => chunks.push(`${key}=`));
|
|
105
|
+
fs.appendFileSync(filePath, `${chunks.join("\n")}\n`, "utf8");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function safeUnlink(filePath) {
|
|
109
|
+
try {
|
|
110
|
+
fs.rmSync(filePath, { force: true });
|
|
111
|
+
} catch (_error) {
|
|
112
|
+
// noop
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function ensureBridge(context, control) {
|
|
117
|
+
const envMeta = normalizeEnvironmentMeta(control, context);
|
|
118
|
+
const bridgePath = context.env.appBridgeFile;
|
|
119
|
+
const exampleBridgePath = context.env.appExampleBridgeFile;
|
|
120
|
+
const sourceEnv = context.env.rootFile;
|
|
121
|
+
const sourceExample = context.env.exampleFile;
|
|
122
|
+
|
|
123
|
+
if (context.layout !== "split") {
|
|
124
|
+
control.meta.environment = { ...envMeta, bridgeMode: "none" };
|
|
125
|
+
return "none";
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
fs.mkdirSync(path.dirname(bridgePath), { recursive: true });
|
|
129
|
+
|
|
130
|
+
let mode = "copy";
|
|
131
|
+
safeUnlink(bridgePath);
|
|
132
|
+
try {
|
|
133
|
+
fs.symlinkSync(path.relative(path.dirname(bridgePath), sourceEnv), bridgePath, "file");
|
|
134
|
+
mode = "symlink";
|
|
135
|
+
} catch (_error) {
|
|
136
|
+
fs.copyFileSync(sourceEnv, bridgePath);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
safeUnlink(exampleBridgePath);
|
|
140
|
+
try {
|
|
141
|
+
fs.symlinkSync(path.relative(path.dirname(exampleBridgePath), sourceExample), exampleBridgePath, "file");
|
|
142
|
+
} catch (_error) {
|
|
143
|
+
fs.copyFileSync(sourceExample, exampleBridgePath);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
control.meta.environment = {
|
|
147
|
+
...envMeta,
|
|
148
|
+
bridgeMode: mode,
|
|
149
|
+
};
|
|
150
|
+
return mode;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function syncEnvironment(contextOrRoot, controlState, options = {}) {
|
|
154
|
+
const context = config.ensureContext(contextOrRoot);
|
|
155
|
+
const control = controlState || config.loadControl(context);
|
|
156
|
+
control.meta = control.meta || {};
|
|
157
|
+
control.meta.environment = normalizeEnvironmentMeta(control, context);
|
|
158
|
+
|
|
159
|
+
const requiredKeys = unique(options.requiredKeys || inferRequiredKeys(control, context));
|
|
160
|
+
const optionalKeys = unique(options.optionalKeys || control.meta.environment.optionalKeys);
|
|
161
|
+
|
|
162
|
+
ensureFileWithHeader(context.env.rootFile, [
|
|
163
|
+
"# TrackOps workspace secrets",
|
|
164
|
+
"# Do not commit this file.",
|
|
165
|
+
]);
|
|
166
|
+
ensureFileWithHeader(context.env.exampleFile, [
|
|
167
|
+
"# TrackOps workspace environment contract",
|
|
168
|
+
"# Safe to commit. Keep only keys, never real values.",
|
|
169
|
+
]);
|
|
170
|
+
|
|
171
|
+
appendMissingKeys(context.env.rootFile, requiredKeys, "# Required keys");
|
|
172
|
+
appendMissingKeys(context.env.exampleFile, requiredKeys, "# Required keys");
|
|
173
|
+
appendMissingKeys(context.env.exampleFile, optionalKeys, "# Optional keys");
|
|
174
|
+
|
|
175
|
+
const bridgeMode = ensureBridge(context, control);
|
|
176
|
+
control.meta.environment = {
|
|
177
|
+
...control.meta.environment,
|
|
178
|
+
requiredKeys,
|
|
179
|
+
optionalKeys,
|
|
180
|
+
bridgeMode,
|
|
181
|
+
lastAuditAt: new Date().toISOString(),
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
config.saveControl(context, control);
|
|
185
|
+
return auditEnvironment(context, control);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function auditEnvironment(contextOrRoot, controlState) {
|
|
189
|
+
const context = config.ensureContext(contextOrRoot);
|
|
190
|
+
const control = controlState || config.loadControl(context);
|
|
191
|
+
const envMeta = normalizeEnvironmentMeta(control, context);
|
|
192
|
+
const requiredKeys = unique(envMeta.requiredKeys.length ? envMeta.requiredKeys : inferRequiredKeys(control, context));
|
|
193
|
+
const envEntries = parseEnv(readText(context.env.rootFile));
|
|
194
|
+
const presentKeys = requiredKeys.filter((key) => String(envEntries[key] || "").trim());
|
|
195
|
+
const missingKeys = requiredKeys.filter((key) => !String(envEntries[key] || "").trim());
|
|
196
|
+
|
|
197
|
+
return {
|
|
198
|
+
ok: true,
|
|
199
|
+
files: {
|
|
200
|
+
rootEnv: context.env.rootFile,
|
|
201
|
+
rootExample: context.env.exampleFile,
|
|
202
|
+
appBridge: context.env.appBridgeFile,
|
|
203
|
+
},
|
|
204
|
+
bridgeMode: envMeta.bridgeMode,
|
|
205
|
+
requiredKeys,
|
|
206
|
+
optionalKeys: envMeta.optionalKeys,
|
|
207
|
+
presentKeys,
|
|
208
|
+
missingKeys,
|
|
209
|
+
lastAuditAt: envMeta.lastAuditAt,
|
|
56
210
|
};
|
|
57
211
|
}
|
|
58
212
|
|
|
59
|
-
function
|
|
60
|
-
const envMeta = control.meta?.environment || {};
|
|
61
|
-
const fromMeta = unique([...(envMeta.requiredKeys || []), ...(envMeta.optionalKeys || [])]);
|
|
62
|
-
const contractServices = readContractServices(contextOrRoot, control);
|
|
63
|
-
const bootstrapServices = unique([
|
|
64
|
-
...(control.meta?.opera?.bootstrap?.discovery?.externalServices || []),
|
|
65
|
-
...(control.meta?.opera?.bootstrap?.externalServices || []),
|
|
66
|
-
]);
|
|
67
|
-
const fromServices = unique(
|
|
68
|
-
(contractServices.length ? contractServices : bootstrapServices)
|
|
69
|
-
.flatMap((service) => SERVICE_ENV_KEYS[service] || []),
|
|
70
|
-
);
|
|
71
|
-
const context = config.ensureContext(contextOrRoot || process.cwd());
|
|
72
|
-
const fromExample = parseEnvKeys(readText(context.env.exampleFile));
|
|
73
|
-
return unique([...fromMeta, ...fromServices, ...fromExample]);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function readContractServices(contextOrRoot, control) {
|
|
77
|
-
const context = config.ensureContext(contextOrRoot || process.cwd());
|
|
78
|
-
const contractFile = context.paths.contractFile;
|
|
79
|
-
if (!fs.existsSync(contractFile)) return [];
|
|
80
|
-
try {
|
|
81
|
-
const contract = JSON.parse(fs.readFileSync(contractFile, "utf8"));
|
|
82
|
-
return Array.isArray(contract?.system?.externalServices) ? contract.system.externalServices : [];
|
|
83
|
-
} catch (_error) {
|
|
84
|
-
return [];
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function ensureFileWithHeader(filePath, lines) {
|
|
89
|
-
if (fs.existsSync(filePath)) return;
|
|
90
|
-
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
91
|
-
fs.writeFileSync(filePath, `${lines.join("\n")}\n`, "utf8");
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function appendMissingKeys(filePath, keys, heading) {
|
|
95
|
-
const existing = readText(filePath);
|
|
96
|
-
const parsed = parseEnvKeys(existing);
|
|
97
|
-
const missing = unique(keys).filter((key) => !parsed.includes(key));
|
|
98
|
-
if (!missing.length) return;
|
|
99
|
-
|
|
100
|
-
const chunks = [];
|
|
101
|
-
if (existing.trim()) chunks.push("");
|
|
102
|
-
if (heading) chunks.push(heading);
|
|
103
|
-
missing.forEach((key) => chunks.push(`${key}=`));
|
|
104
|
-
fs.appendFileSync(filePath, `${chunks.join("\n")}\n`, "utf8");
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function safeUnlink(filePath) {
|
|
108
|
-
try {
|
|
109
|
-
fs.rmSync(filePath, { force: true });
|
|
110
|
-
} catch (_error) {
|
|
111
|
-
// noop
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function ensureBridge(context, control) {
|
|
116
|
-
const envMeta = normalizeEnvironmentMeta(control, context);
|
|
117
|
-
const bridgePath = context.env.appBridgeFile;
|
|
118
|
-
const exampleBridgePath = context.env.appExampleBridgeFile;
|
|
119
|
-
const sourceEnv = context.env.rootFile;
|
|
120
|
-
const sourceExample = context.env.exampleFile;
|
|
121
|
-
|
|
122
|
-
if (context.layout !== "split") {
|
|
123
|
-
control.meta.environment = { ...envMeta, bridgeMode: "none" };
|
|
124
|
-
return "none";
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
fs.mkdirSync(path.dirname(bridgePath), { recursive: true });
|
|
128
|
-
|
|
129
|
-
let mode = "copy";
|
|
130
|
-
safeUnlink(bridgePath);
|
|
131
|
-
try {
|
|
132
|
-
fs.symlinkSync(path.relative(path.dirname(bridgePath), sourceEnv), bridgePath, "file");
|
|
133
|
-
mode = "symlink";
|
|
134
|
-
} catch (_error) {
|
|
135
|
-
fs.copyFileSync(sourceEnv, bridgePath);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
safeUnlink(exampleBridgePath);
|
|
213
|
+
function initLocale(contextOrRoot) {
|
|
139
214
|
try {
|
|
140
|
-
|
|
215
|
+
const control = config.loadControl(config.ensureContext(contextOrRoot));
|
|
216
|
+
setLocale(config.getLocale(control));
|
|
141
217
|
} catch (_error) {
|
|
142
|
-
|
|
218
|
+
setLocale("es");
|
|
143
219
|
}
|
|
144
|
-
|
|
145
|
-
control.meta.environment = {
|
|
146
|
-
...envMeta,
|
|
147
|
-
bridgeMode: mode,
|
|
148
|
-
};
|
|
149
|
-
return mode;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function syncEnvironment(contextOrRoot, controlState, options = {}) {
|
|
153
|
-
const context = config.ensureContext(contextOrRoot);
|
|
154
|
-
const control = controlState || config.loadControl(context);
|
|
155
|
-
control.meta = control.meta || {};
|
|
156
|
-
control.meta.environment = normalizeEnvironmentMeta(control, context);
|
|
157
|
-
|
|
158
|
-
const requiredKeys = unique(options.requiredKeys || inferRequiredKeys(control, context));
|
|
159
|
-
const optionalKeys = unique(options.optionalKeys || control.meta.environment.optionalKeys);
|
|
160
|
-
|
|
161
|
-
ensureFileWithHeader(context.env.rootFile, [
|
|
162
|
-
"# TrackOps workspace secrets",
|
|
163
|
-
"# Do not commit this file.",
|
|
164
|
-
]);
|
|
165
|
-
ensureFileWithHeader(context.env.exampleFile, [
|
|
166
|
-
"# TrackOps workspace environment contract",
|
|
167
|
-
"# Safe to commit. Keep only keys, never real values.",
|
|
168
|
-
]);
|
|
169
|
-
|
|
170
|
-
appendMissingKeys(context.env.rootFile, requiredKeys, "# Required keys");
|
|
171
|
-
appendMissingKeys(context.env.exampleFile, requiredKeys, "# Required keys");
|
|
172
|
-
appendMissingKeys(context.env.exampleFile, optionalKeys, "# Optional keys");
|
|
173
|
-
|
|
174
|
-
const bridgeMode = ensureBridge(context, control);
|
|
175
|
-
control.meta.environment = {
|
|
176
|
-
...control.meta.environment,
|
|
177
|
-
requiredKeys,
|
|
178
|
-
optionalKeys,
|
|
179
|
-
bridgeMode,
|
|
180
|
-
lastAuditAt: new Date().toISOString(),
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
config.saveControl(context, control);
|
|
184
|
-
return auditEnvironment(context, control);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function auditEnvironment(contextOrRoot, controlState) {
|
|
188
|
-
const context = config.ensureContext(contextOrRoot);
|
|
189
|
-
const control = controlState || config.loadControl(context);
|
|
190
|
-
const envMeta = normalizeEnvironmentMeta(control, context);
|
|
191
|
-
const requiredKeys = unique(envMeta.requiredKeys.length ? envMeta.requiredKeys : inferRequiredKeys(control, context));
|
|
192
|
-
const envEntries = parseEnv(readText(context.env.rootFile));
|
|
193
|
-
const presentKeys = requiredKeys.filter((key) => String(envEntries[key] || "").trim());
|
|
194
|
-
const missingKeys = requiredKeys.filter((key) => !String(envEntries[key] || "").trim());
|
|
195
|
-
|
|
196
|
-
return {
|
|
197
|
-
ok: true,
|
|
198
|
-
files: {
|
|
199
|
-
rootEnv: context.env.rootFile,
|
|
200
|
-
rootExample: context.env.exampleFile,
|
|
201
|
-
appBridge: context.env.appBridgeFile,
|
|
202
|
-
},
|
|
203
|
-
bridgeMode: envMeta.bridgeMode,
|
|
204
|
-
requiredKeys,
|
|
205
|
-
optionalKeys: envMeta.optionalKeys,
|
|
206
|
-
presentKeys,
|
|
207
|
-
missingKeys,
|
|
208
|
-
lastAuditAt: envMeta.lastAuditAt,
|
|
209
|
-
};
|
|
210
220
|
}
|
|
211
221
|
|
|
212
222
|
function cmdStatus(contextOrRoot) {
|
|
223
|
+
initLocale(contextOrRoot);
|
|
213
224
|
const audit = auditEnvironment(contextOrRoot);
|
|
214
|
-
console.log("
|
|
215
|
-
console.log(
|
|
216
|
-
console.log(
|
|
217
|
-
console.log(
|
|
218
|
-
console.log(
|
|
219
|
-
console.log(
|
|
220
|
-
console.log(
|
|
221
|
-
console.log(
|
|
225
|
+
console.log(t("env.status.title"));
|
|
226
|
+
console.log(t("env.status.rootEnv", { path: audit.files.rootEnv }));
|
|
227
|
+
console.log(t("env.status.example", { path: audit.files.rootExample }));
|
|
228
|
+
console.log(t("env.status.appBridge", { path: audit.files.appBridge }));
|
|
229
|
+
console.log(t("env.status.bridgeMode", { value: audit.bridgeMode }));
|
|
230
|
+
console.log(t("env.status.required", { value: audit.requiredKeys.length ? audit.requiredKeys.join(", ") : t("locale.none") }));
|
|
231
|
+
console.log(t("env.status.present", { value: audit.presentKeys.length ? audit.presentKeys.join(", ") : t("locale.none") }));
|
|
232
|
+
console.log(t("env.status.missing", { value: audit.missingKeys.length ? audit.missingKeys.join(", ") : t("locale.none") }));
|
|
222
233
|
}
|
|
223
234
|
|
|
224
235
|
function cmdSync(contextOrRoot) {
|
|
236
|
+
initLocale(contextOrRoot);
|
|
225
237
|
const context = config.ensureContext(contextOrRoot);
|
|
226
238
|
const control = config.loadControl(context);
|
|
227
239
|
const audit = syncEnvironment(context, control);
|
|
228
|
-
console.log(
|
|
240
|
+
console.log(t("env.sync.updated", { path: path.relative(context.workspaceRoot, context.env.rootFile) }));
|
|
229
241
|
if (audit.missingKeys.length) {
|
|
230
|
-
console.log(
|
|
242
|
+
console.log(t("env.sync.missing", { value: audit.missingKeys.join(", ") }));
|
|
231
243
|
}
|
|
232
244
|
}
|
|
233
|
-
|
|
234
|
-
module.exports = {
|
|
235
|
-
SERVICE_ENV_KEYS,
|
|
236
|
-
parseEnv,
|
|
237
|
-
parseEnvKeys,
|
|
238
|
-
normalizeEnvironmentMeta,
|
|
239
|
-
inferRequiredKeys,
|
|
240
|
-
syncEnvironment,
|
|
241
|
-
auditEnvironment,
|
|
242
|
-
cmdStatus,
|
|
243
|
-
cmdSync,
|
|
244
|
-
};
|
|
245
|
+
|
|
246
|
+
module.exports = {
|
|
247
|
+
SERVICE_ENV_KEYS,
|
|
248
|
+
parseEnv,
|
|
249
|
+
parseEnvKeys,
|
|
250
|
+
normalizeEnvironmentMeta,
|
|
251
|
+
inferRequiredKeys,
|
|
252
|
+
syncEnvironment,
|
|
253
|
+
auditEnvironment,
|
|
254
|
+
cmdStatus,
|
|
255
|
+
cmdSync,
|
|
256
|
+
};
|
package/lib/i18n.js
CHANGED
|
@@ -38,10 +38,11 @@ function getLocale() {
|
|
|
38
38
|
|
|
39
39
|
function t(key, params) {
|
|
40
40
|
ensureLoaded();
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
key;
|
|
41
|
+
const found = currentMessages[key] || (fallbackMessages && fallbackMessages[key]);
|
|
42
|
+
let message = found || key;
|
|
43
|
+
if (!found && process.env.NODE_ENV !== "production" && process.env.TRACKOPS_DEBUG) {
|
|
44
|
+
process.stderr.write(`[i18n] Missing key: ${key}\n`);
|
|
45
|
+
}
|
|
45
46
|
if (params) {
|
|
46
47
|
message = message.replace(/\{(\w+)\}/g, (match, paramKey) =>
|
|
47
48
|
params[paramKey] !== undefined ? String(params[paramKey]) : match
|