@vsceasy/cli 0.1.8 → 0.1.10
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/CHANGELOG.md +4 -0
- package/README.md +40 -0
- package/dist/bin/cli.js +858 -76
- package/dist/index.js +717 -19
- package/dist/lib/config.d.ts +2 -0
- package/dist/lib/contributesMerge.d.ts +18 -0
- package/dist/lib/crud/parseModel.d.ts +12 -0
- package/dist/lib/helper/add.d.ts +1 -1
- package/dist/lib/model/add.d.ts +18 -0
- package/dist/lib/model/parseFields.d.ts +9 -3
- package/dist/lib/scaffold.d.ts +4 -0
- package/dist/lib/templatesData.d.ts +1 -1
- package/package.json +1 -1
- package/templates/_assets/language/README.language.md +39 -0
- package/templates/_assets/language/contributes.extra.json +40 -0
- package/templates/_assets/language/fileicons/{{langId}}-icon-theme.json +13 -0
- package/templates/_assets/language/icons/{{langId}}.svg +5 -0
- package/templates/_assets/language/language-configuration.json +30 -0
- package/templates/_assets/language/snippets/{{langId}}.json +12 -0
- package/templates/_assets/language/src/colorize.ts +31 -0
- package/templates/_assets/language/src/commands/applyColors.ts +11 -0
- package/templates/_assets/language/src/commands/removeColors.ts +11 -0
- package/templates/_assets/language/src/extension/extension.ts +25 -0
- package/templates/_assets/language/src/helpers/colorize.ts +70 -0
- package/templates/_assets/language/syntaxes/{{langId}}.tmLanguage.json +45 -0
- package/templates/_generators/crud/formApp.tsx.tpl +2 -0
- package/templates/_generators/crud/formPanel.ts.tpl +2 -2
- package/templates/_generators/helper/colorize.ts.tpl +85 -0
- package/templates/_generators/model/model.ts.tpl +1 -1
- package/templates/react/scripts/gen.ts +55 -0
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// Scans src/panels, src/commands, and src/menus; writes src/extension/_registry.ts
|
|
3
3
|
// and syncs package.json#contributes (commands, viewsContainers, views).
|
|
4
|
+
//
|
|
5
|
+
// Non-generated contributes (e.g. languages, grammars, snippets, themes,
|
|
6
|
+
// iconThemes, walkthroughs) go in an optional `contributes.extra.json` at the
|
|
7
|
+
// project root. It is deep-merged into package.json#contributes on every run —
|
|
8
|
+
// the keys gen.ts owns (commands, keybindings, menus.commandPalette,
|
|
9
|
+
// viewsContainers, views) always win, everything else from extra is preserved.
|
|
4
10
|
|
|
5
11
|
import * as fs from 'fs';
|
|
6
12
|
import * as path from 'path';
|
|
@@ -16,6 +22,10 @@ const TREE_VIEWS_DIR = path.join(SRC, 'treeViews');
|
|
|
16
22
|
const JOBS_DIR = path.join(SRC, 'jobs');
|
|
17
23
|
const OUT = path.join(SRC, 'extension', '_registry.ts');
|
|
18
24
|
const PKG_PATH = path.join(ROOT, 'package.json');
|
|
25
|
+
const EXTRA_PATH = path.join(ROOT, 'contributes.extra.json');
|
|
26
|
+
|
|
27
|
+
/** Keys gen.ts owns — never overridden by contributes.extra.json. */
|
|
28
|
+
const GEN_OWNED_KEYS = new Set(['commands', 'keybindings', 'viewsContainers', 'views']);
|
|
19
29
|
|
|
20
30
|
interface Discovered {
|
|
21
31
|
id: string;
|
|
@@ -204,9 +214,54 @@ function syncPackageJson(
|
|
|
204
214
|
delete contributes.views;
|
|
205
215
|
}
|
|
206
216
|
|
|
217
|
+
mergeExtraContributes(contributes);
|
|
218
|
+
|
|
207
219
|
fs.writeFileSync(PKG_PATH, JSON.stringify(pkg, null, 2) + '\n');
|
|
208
220
|
}
|
|
209
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Deep-merge the optional `contributes.extra.json` (project root) into the
|
|
224
|
+
* package's `contributes`. Use for any contribution point gen.ts doesn't
|
|
225
|
+
* generate — languages, grammars, snippets, themes, iconThemes, walkthroughs…
|
|
226
|
+
*
|
|
227
|
+
* Rules:
|
|
228
|
+
* - gen-owned keys (commands, keybindings, viewsContainers, views) are ignored
|
|
229
|
+
* if present in extra — gen.ts stays authoritative for those.
|
|
230
|
+
* - plain objects merge recursively; arrays and primitives from extra replace.
|
|
231
|
+
*
|
|
232
|
+
* NOTE: this is an inline copy of src/lib/contributesMerge.ts in the vsceasy
|
|
233
|
+
* source (the script must run standalone). Keep the two in sync.
|
|
234
|
+
*/
|
|
235
|
+
function mergeExtraContributes(contributes: Record<string, any>) {
|
|
236
|
+
if (!fs.existsSync(EXTRA_PATH)) return;
|
|
237
|
+
let extra: Record<string, any>;
|
|
238
|
+
try {
|
|
239
|
+
extra = JSON.parse(fs.readFileSync(EXTRA_PATH, 'utf8'));
|
|
240
|
+
} catch (err) {
|
|
241
|
+
console.warn(`! Skipping contributes.extra.json — invalid JSON: ${(err as Error).message}`);
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (!extra || typeof extra !== 'object') return;
|
|
245
|
+
for (const [key, value] of Object.entries(extra)) {
|
|
246
|
+
if (GEN_OWNED_KEYS.has(key)) continue;
|
|
247
|
+
contributes[key] = deepMerge(contributes[key], value);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function isPlainObject(v: unknown): v is Record<string, any> {
|
|
252
|
+
return typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function deepMerge(base: any, override: any): any {
|
|
256
|
+
if (isPlainObject(base) && isPlainObject(override)) {
|
|
257
|
+
const out: Record<string, any> = { ...base };
|
|
258
|
+
for (const [k, v] of Object.entries(override)) out[k] = deepMerge(base[k], v);
|
|
259
|
+
return out;
|
|
260
|
+
}
|
|
261
|
+
// arrays and primitives: override wins
|
|
262
|
+
return override;
|
|
263
|
+
}
|
|
264
|
+
|
|
210
265
|
function loadDef(file: string): {
|
|
211
266
|
id?: string;
|
|
212
267
|
title?: string;
|