@wix/web50-cli 0.1.1 → 0.1.2
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/bin/web5.js +1 -2
- package/dist/cjs/auth/deviceFlow.js +90 -17
- package/dist/cjs/auth/deviceFlow.js.map +1 -1
- package/dist/cjs/auth/index.js +40 -10
- package/dist/cjs/auth/index.js.map +1 -1
- package/dist/cjs/cli.js +3 -3
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/commands/bundle.js +12 -4
- package/dist/cjs/commands/bundle.js.map +1 -1
- package/dist/cjs/commands/conversation.js.map +1 -1
- package/dist/cjs/commands/conversationWizard.js +3 -1
- package/dist/cjs/commands/conversationWizard.js.map +1 -1
- package/dist/cjs/commands/deploy.js +55 -10
- package/dist/cjs/commands/deploy.js.map +1 -1
- package/dist/cjs/commands/ecom.js +239 -0
- package/dist/cjs/commands/ecom.js.map +1 -0
- package/dist/cjs/commands/embed.js.map +1 -1
- package/dist/cjs/commands/init.js +34 -3
- package/dist/cjs/commands/init.js.map +1 -1
- package/dist/cjs/commands/instructions.js +147 -51
- package/dist/cjs/commands/instructions.js.map +1 -1
- package/dist/cjs/commands/login.js +8 -4
- package/dist/cjs/commands/login.js.map +1 -1
- package/dist/cjs/commands/serve.js.map +1 -1
- package/dist/cjs/commands/validate.js +368 -16
- package/dist/cjs/commands/validate.js.map +1 -1
- package/dist/cjs/commands/whoami.js.map +1 -1
- package/dist/cjs/templates/aiInstructionsSchema.js +5 -1
- package/dist/cjs/templates/aiInstructionsSchema.js.map +1 -1
- package/dist/cjs/templates/cmsMappingSchema.js +132 -0
- package/dist/cjs/templates/cmsMappingSchema.js.map +1 -0
- package/dist/cjs/utils/project.js +13 -0
- package/dist/cjs/utils/project.js.map +1 -1
- package/dist/cjs/utils/wixApi.js +3 -1
- package/dist/cjs/utils/wixApi.js.map +1 -1
- package/dist/esm/auth/deviceFlow.js +89 -17
- package/dist/esm/auth/deviceFlow.js.map +1 -1
- package/dist/esm/auth/index.js +40 -11
- package/dist/esm/auth/index.js.map +1 -1
- package/dist/esm/cli.js +3 -3
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/commands/bundle.js +12 -4
- package/dist/esm/commands/bundle.js.map +1 -1
- package/dist/esm/commands/conversation.js.map +1 -1
- package/dist/esm/commands/conversationWizard.js +3 -1
- package/dist/esm/commands/conversationWizard.js.map +1 -1
- package/dist/esm/commands/deploy.js +55 -10
- package/dist/esm/commands/deploy.js.map +1 -1
- package/dist/esm/commands/ecom.js +234 -0
- package/dist/esm/commands/ecom.js.map +1 -0
- package/dist/esm/commands/embed.js.map +1 -1
- package/dist/esm/commands/init.js +34 -3
- package/dist/esm/commands/init.js.map +1 -1
- package/dist/esm/commands/instructions.js +152 -53
- package/dist/esm/commands/instructions.js.map +1 -1
- package/dist/esm/commands/login.js +8 -4
- package/dist/esm/commands/login.js.map +1 -1
- package/dist/esm/commands/serve.js.map +1 -1
- package/dist/esm/commands/validate.js +373 -19
- package/dist/esm/commands/validate.js.map +1 -1
- package/dist/esm/commands/whoami.js.map +1 -1
- package/dist/esm/templates/aiInstructionsSchema.js +5 -1
- package/dist/esm/templates/aiInstructionsSchema.js.map +1 -1
- package/dist/esm/templates/cmsMappingSchema.js +128 -0
- package/dist/esm/templates/cmsMappingSchema.js.map +1 -0
- package/dist/esm/utils/project.js +15 -0
- package/dist/esm/utils/project.js.map +1 -1
- package/dist/esm/utils/wixApi.js +4 -2
- package/dist/esm/utils/wixApi.js.map +1 -1
- package/dist/types/auth/deviceFlow.d.ts +1 -1
- package/dist/types/auth/deviceFlow.d.ts.map +1 -1
- package/dist/types/auth/index.d.ts +2 -1
- package/dist/types/auth/index.d.ts.map +1 -1
- package/dist/types/commands/bundle.d.ts.map +1 -1
- package/dist/types/commands/conversation.d.ts.map +1 -1
- package/dist/types/commands/conversationWizard.d.ts.map +1 -1
- package/dist/types/commands/deploy.d.ts.map +1 -1
- package/dist/types/commands/ecom.d.ts +3 -0
- package/dist/types/commands/ecom.d.ts.map +1 -0
- package/dist/types/commands/embed.d.ts.map +1 -1
- package/dist/types/commands/init.d.ts.map +1 -1
- package/dist/types/commands/instructions.d.ts.map +1 -1
- package/dist/types/commands/login.d.ts.map +1 -1
- package/dist/types/commands/serve.d.ts.map +1 -1
- package/dist/types/commands/validate.d.ts +4 -2
- package/dist/types/commands/validate.d.ts.map +1 -1
- package/dist/types/commands/whoami.d.ts.map +1 -1
- package/dist/types/templates/aiInstructionsSchema.d.ts.map +1 -1
- package/dist/types/templates/cmsMappingSchema.d.ts +2 -0
- package/dist/types/templates/cmsMappingSchema.d.ts.map +1 -0
- package/dist/types/utils/project.d.ts +2 -0
- package/dist/types/utils/project.d.ts.map +1 -1
- package/dist/types/utils/wixApi.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/cjs/commands/getClientId.js +0 -60
- package/dist/cjs/commands/getClientId.js.map +0 -1
- package/dist/esm/commands/getClientId.js +0 -56
- package/dist/esm/commands/getClientId.js.map +0 -1
- package/dist/types/commands/getClientId.d.ts +0 -3
- package/dist/types/commands/getClientId.d.ts.map +0 -1
|
@@ -12,6 +12,7 @@ var path = _interopRequireWildcard(require("path"));
|
|
|
12
12
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
13
13
|
var _print = require("../utils/print");
|
|
14
14
|
var _cmsSchemaSchema = require("../templates/cmsSchemaSchema");
|
|
15
|
+
var _cmsMappingSchema = require("../templates/cmsMappingSchema");
|
|
15
16
|
var _aiInstructionsSchema = require("../templates/aiInstructionsSchema");
|
|
16
17
|
var _actionYamlSchema = require("../templates/actionYamlSchema");
|
|
17
18
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
@@ -19,6 +20,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
19
20
|
|
|
20
21
|
const SCHEMAS = {
|
|
21
22
|
'cms-schema.yaml': (0, _jsYaml.load)((0, _cmsSchemaSchema.cmsSchemaSchemaTemplate)()),
|
|
23
|
+
'cms-mapping.yaml': (0, _jsYaml.load)((0, _cmsMappingSchema.cmsMappingSchemaTemplate)()),
|
|
22
24
|
'prompt-instructions.yaml': (0, _jsYaml.load)((0, _aiInstructionsSchema.aiInstructionsSchemaTemplate)()),
|
|
23
25
|
'action.yaml': (0, _jsYaml.load)((0, _actionYamlSchema.actionYamlSchemaTemplate)())
|
|
24
26
|
};
|
|
@@ -296,6 +298,91 @@ function buildCmsSchemaDomain(root) {
|
|
|
296
298
|
}]
|
|
297
299
|
};
|
|
298
300
|
}
|
|
301
|
+
function buildCmsMappingDomain(root) {
|
|
302
|
+
const filePath = path.join(root, 'src', 'configuration', 'cms', 'cms-mapping.yaml');
|
|
303
|
+
const fileName = 'cms-mapping.yaml';
|
|
304
|
+
const ajv = new _2.default({
|
|
305
|
+
allErrors: true,
|
|
306
|
+
strict: false
|
|
307
|
+
});
|
|
308
|
+
const schema = SCHEMAS[fileName];
|
|
309
|
+
let parsed;
|
|
310
|
+
let fileExists = false;
|
|
311
|
+
let yamlOk = false;
|
|
312
|
+
return {
|
|
313
|
+
name: 'CMS Mapping',
|
|
314
|
+
checks: [{
|
|
315
|
+
label: `${fileName} — file exists`,
|
|
316
|
+
run() {
|
|
317
|
+
fileExists = (0, _fs.existsSync)(filePath);
|
|
318
|
+
if (fileExists) {
|
|
319
|
+
return {
|
|
320
|
+
ok: true,
|
|
321
|
+
errors: []
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
return {
|
|
325
|
+
ok: false,
|
|
326
|
+
errors: [{
|
|
327
|
+
message: `File not found: ${filePath}`,
|
|
328
|
+
fix: `Create 'src/configuration/cms/cms-mapping.yaml' in your project.`
|
|
329
|
+
}]
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
}, {
|
|
333
|
+
label: `${fileName} — valid YAML`,
|
|
334
|
+
run() {
|
|
335
|
+
if (!fileExists) {
|
|
336
|
+
return {
|
|
337
|
+
ok: false,
|
|
338
|
+
errors: [{
|
|
339
|
+
message: 'skipped — file does not exist'
|
|
340
|
+
}]
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
const result = tryParseYaml(filePath);
|
|
344
|
+
if (result.err !== undefined) {
|
|
345
|
+
return {
|
|
346
|
+
ok: false,
|
|
347
|
+
errors: [{
|
|
348
|
+
message: result.err,
|
|
349
|
+
fix: 'Fix the YAML syntax error above.'
|
|
350
|
+
}]
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
parsed = result.data;
|
|
354
|
+
yamlOk = true;
|
|
355
|
+
return {
|
|
356
|
+
ok: true,
|
|
357
|
+
errors: []
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
}, {
|
|
361
|
+
label: `${fileName} — schema valid`,
|
|
362
|
+
run() {
|
|
363
|
+
if (!yamlOk) {
|
|
364
|
+
return {
|
|
365
|
+
ok: false,
|
|
366
|
+
errors: [{
|
|
367
|
+
message: 'skipped — YAML parse failed'
|
|
368
|
+
}]
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
const validate = ajv.compile(schema);
|
|
372
|
+
if (validate(parsed)) {
|
|
373
|
+
return {
|
|
374
|
+
ok: true,
|
|
375
|
+
errors: []
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
return {
|
|
379
|
+
ok: false,
|
|
380
|
+
errors: (validate.errors ?? []).map(e => formatAjvError(e))
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
}]
|
|
384
|
+
};
|
|
385
|
+
}
|
|
299
386
|
function buildActionsDomain(root) {
|
|
300
387
|
const actionsDir = path.join(root, 'src', 'actions');
|
|
301
388
|
const registryPath = path.join(root, 'src', 'createRegistry.ts');
|
|
@@ -669,6 +756,260 @@ function buildActionsDomain(root) {
|
|
|
669
756
|
};
|
|
670
757
|
}
|
|
671
758
|
|
|
759
|
+
// ── Sections helpers ──────────────────────────────────────────────────────────
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* Extracts the text of every `.register(...)` call that has a component array.
|
|
763
|
+
* Uses bracket-counting to handle nesting correctly.
|
|
764
|
+
* Skips system registrations that have no `[` (e.g. SkipNodesSectionDefinition).
|
|
765
|
+
*/
|
|
766
|
+
function extractRegisterBlocks(content) {
|
|
767
|
+
const blocks = [];
|
|
768
|
+
const marker = '.register(';
|
|
769
|
+
let searchFrom = 0;
|
|
770
|
+
let start = content.indexOf(marker, searchFrom);
|
|
771
|
+
while (start !== -1) {
|
|
772
|
+
let depth = 0;
|
|
773
|
+
let i = start + marker.length - 1; // position of the opening '('
|
|
774
|
+
while (i < content.length) {
|
|
775
|
+
const ch = content[i];
|
|
776
|
+
if (ch === '(') {
|
|
777
|
+
depth++;
|
|
778
|
+
} else if (ch === ')') {
|
|
779
|
+
depth--;
|
|
780
|
+
if (depth === 0) {
|
|
781
|
+
break;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
i++;
|
|
785
|
+
}
|
|
786
|
+
const block = content.slice(start, i + 1);
|
|
787
|
+
if (block.includes('[')) {
|
|
788
|
+
blocks.push(block);
|
|
789
|
+
}
|
|
790
|
+
searchFrom = i + 1;
|
|
791
|
+
start = content.indexOf(marker, searchFrom);
|
|
792
|
+
}
|
|
793
|
+
return blocks;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* Scans all import lines that reference a `sections/` path and returns a
|
|
798
|
+
* Map<localName, stem>. Handles aliases and multi-name imports:
|
|
799
|
+
* import { KpiSection as KpiSectionComponent } from '...sections/KpiSection'
|
|
800
|
+
* → "KpiSectionComponent" → "KpiSection"
|
|
801
|
+
*/
|
|
802
|
+
function buildSectionImportMap(content) {
|
|
803
|
+
const map = new Map();
|
|
804
|
+
const re = /import\s*\{([^}]+)\}\s*from\s*['"][^'"]*sections\/(\w+)['"]/g;
|
|
805
|
+
let m = re.exec(content);
|
|
806
|
+
while (m !== null) {
|
|
807
|
+
const stem = m[2];
|
|
808
|
+
const names = m[1].split(',');
|
|
809
|
+
for (const raw of names) {
|
|
810
|
+
const token = raw.trim();
|
|
811
|
+
if (!token) {
|
|
812
|
+
continue;
|
|
813
|
+
}
|
|
814
|
+
const asParts = token.split(/\s+as\s+/);
|
|
815
|
+
const localName = (asParts[1] ?? asParts[0]).trim();
|
|
816
|
+
if (localName) {
|
|
817
|
+
map.set(localName, stem);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
m = re.exec(content);
|
|
821
|
+
}
|
|
822
|
+
return map;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
// ── Sections domain ────────────────────────────────────────────────────────────
|
|
826
|
+
|
|
827
|
+
function buildSectionsDomain(root) {
|
|
828
|
+
const registryPath = path.join(root, 'src', 'createRegistry.ts');
|
|
829
|
+
const sectionsDir = path.join(root, 'src', 'components', 'sections');
|
|
830
|
+
let registryExists = false;
|
|
831
|
+
let registryContent = '';
|
|
832
|
+
let tsxFiles = [];
|
|
833
|
+
return {
|
|
834
|
+
name: 'Sections',
|
|
835
|
+
checks: [
|
|
836
|
+
// ── Check 1: createRegistry.ts exists ────────────────────────────────
|
|
837
|
+
{
|
|
838
|
+
label: 'createRegistry.ts — file exists',
|
|
839
|
+
run() {
|
|
840
|
+
registryExists = (0, _fs.existsSync)(registryPath);
|
|
841
|
+
if (!registryExists) {
|
|
842
|
+
return {
|
|
843
|
+
ok: false,
|
|
844
|
+
errors: [{
|
|
845
|
+
message: 'src/createRegistry.ts not found',
|
|
846
|
+
fix: 'Create src/createRegistry.ts and export a createRegistry() function that registers your section components.'
|
|
847
|
+
}]
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
registryContent = readText(registryPath);
|
|
851
|
+
tsxFiles = (0, _fs.existsSync)(sectionsDir) ? (0, _fs.readdirSync)(sectionsDir).filter(f => f.endsWith('.tsx')) : [];
|
|
852
|
+
return {
|
|
853
|
+
ok: true,
|
|
854
|
+
errors: []
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
},
|
|
858
|
+
// ── Check 2: all .tsx files imported in createRegistry.ts ─────────────
|
|
859
|
+
{
|
|
860
|
+
label: 'src/components/sections/ — all .tsx files imported in createRegistry.ts',
|
|
861
|
+
run() {
|
|
862
|
+
if (!registryExists) {
|
|
863
|
+
return {
|
|
864
|
+
ok: false,
|
|
865
|
+
errors: [{
|
|
866
|
+
message: 'skipped — createRegistry.ts not found'
|
|
867
|
+
}]
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
const errors = [];
|
|
871
|
+
for (const file of tsxFiles) {
|
|
872
|
+
const stem = path.basename(file, '.tsx');
|
|
873
|
+
if (!registryContent.includes(`sections/${stem}`)) {
|
|
874
|
+
errors.push({
|
|
875
|
+
message: `'${stem}.tsx' is not imported in src/createRegistry.ts`,
|
|
876
|
+
fix: `Add: import { ${stem} } from './components/sections/${stem}';`
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
return errors.length === 0 ? {
|
|
881
|
+
ok: true,
|
|
882
|
+
errors: []
|
|
883
|
+
} : {
|
|
884
|
+
ok: false,
|
|
885
|
+
errors
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
},
|
|
889
|
+
// ── Check 3: all .tsx files wired into a .register() call ─────────────
|
|
890
|
+
{
|
|
891
|
+
label: 'src/components/sections/ — all .tsx files wired into .register()',
|
|
892
|
+
run() {
|
|
893
|
+
if (!registryExists) {
|
|
894
|
+
return {
|
|
895
|
+
ok: false,
|
|
896
|
+
errors: [{
|
|
897
|
+
message: 'skipped — createRegistry.ts not found'
|
|
898
|
+
}]
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
const importMap = buildSectionImportMap(registryContent);
|
|
902
|
+
const blocks = extractRegisterBlocks(registryContent);
|
|
903
|
+
const blockText = blocks.join('\n');
|
|
904
|
+
const errors = [];
|
|
905
|
+
for (const file of tsxFiles) {
|
|
906
|
+
var _find;
|
|
907
|
+
const stem = path.basename(file, '.tsx');
|
|
908
|
+
// Find the local name for this stem (may have been aliased on import)
|
|
909
|
+
const localName = ((_find = [...importMap.entries()].find(([, s]) => s === stem)) == null ? void 0 : _find[0]) ?? stem;
|
|
910
|
+
if (!blockText.includes(localName)) {
|
|
911
|
+
errors.push({
|
|
912
|
+
message: `'${localName}' (${stem}.tsx) is imported but not passed to any .register() call`,
|
|
913
|
+
fix: `Add { component: ${localName} } inside a .register(new <Definition>(), [...]) call in src/createRegistry.ts.`
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
return errors.length === 0 ? {
|
|
918
|
+
ok: true,
|
|
919
|
+
errors: []
|
|
920
|
+
} : {
|
|
921
|
+
ok: false,
|
|
922
|
+
errors
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
},
|
|
926
|
+
// ── Check 4: every .register() block has a catch-all entry ────────────
|
|
927
|
+
{
|
|
928
|
+
label: 'createRegistry.ts — all .register() blocks have a catch-all component',
|
|
929
|
+
run() {
|
|
930
|
+
if (!registryExists) {
|
|
931
|
+
return {
|
|
932
|
+
ok: false,
|
|
933
|
+
errors: [{
|
|
934
|
+
message: 'skipped — createRegistry.ts not found'
|
|
935
|
+
}]
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
const blocks = extractRegisterBlocks(registryContent);
|
|
939
|
+
const errors = [];
|
|
940
|
+
for (const block of blocks) {
|
|
941
|
+
const defMatch = block.match(/\.register\(\s*new\s+(\w+)/);
|
|
942
|
+
const defName = defMatch ? defMatch[1] : '(unknown)';
|
|
943
|
+
|
|
944
|
+
// Split on "{ component:" to isolate each entry
|
|
945
|
+
const entries = block.split('{ component:').slice(1);
|
|
946
|
+
if (entries.length === 0) {
|
|
947
|
+
continue;
|
|
948
|
+
}
|
|
949
|
+
const allHaveIntent = entries.every(entry => entry.includes('intent:'));
|
|
950
|
+
if (allHaveIntent) {
|
|
951
|
+
errors.push({
|
|
952
|
+
message: `'${defName}' has no catch-all component — every entry specifies an intent`,
|
|
953
|
+
fix: `Add a catch-all entry to the .register(new ${defName}(), [...]) call:\n { component: YourDefaultComponent }`
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
return errors.length === 0 ? {
|
|
958
|
+
ok: true,
|
|
959
|
+
errors: []
|
|
960
|
+
} : {
|
|
961
|
+
ok: false,
|
|
962
|
+
errors
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
},
|
|
966
|
+
// ── Check 5: all component refs in .register() resolve to a .tsx file ─
|
|
967
|
+
{
|
|
968
|
+
label: 'createRegistry.ts — all .register() component references resolve to a .tsx file',
|
|
969
|
+
run() {
|
|
970
|
+
if (!registryExists) {
|
|
971
|
+
return {
|
|
972
|
+
ok: false,
|
|
973
|
+
errors: [{
|
|
974
|
+
message: 'skipped — createRegistry.ts not found'
|
|
975
|
+
}]
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
const importMap = buildSectionImportMap(registryContent);
|
|
979
|
+
const blocks = extractRegisterBlocks(registryContent);
|
|
980
|
+
const errors = [];
|
|
981
|
+
for (const block of blocks) {
|
|
982
|
+
const refs = [...block.matchAll(/\{\s*component:\s*(\w+)/g)].map(m => m[1]);
|
|
983
|
+
for (const ref of refs) {
|
|
984
|
+
const stem = importMap.get(ref);
|
|
985
|
+
if (stem === undefined) {
|
|
986
|
+
errors.push({
|
|
987
|
+
message: `Component '${ref}' used in .register() has no matching import from sections/`,
|
|
988
|
+
fix: `Add: import { ${ref} } from './components/sections/${ref}'; or check the import alias.`
|
|
989
|
+
});
|
|
990
|
+
continue;
|
|
991
|
+
}
|
|
992
|
+
const filePath = path.join(sectionsDir, `${stem}.tsx`);
|
|
993
|
+
if (!(0, _fs.existsSync)(filePath)) {
|
|
994
|
+
errors.push({
|
|
995
|
+
message: `Component '${ref}' maps to '${stem}.tsx' which does not exist in src/components/sections/`,
|
|
996
|
+
fix: `Create src/components/sections/${stem}.tsx, or remove the stale .register() entry from src/createRegistry.ts.`
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
return errors.length === 0 ? {
|
|
1002
|
+
ok: true,
|
|
1003
|
+
errors: []
|
|
1004
|
+
} : {
|
|
1005
|
+
ok: false,
|
|
1006
|
+
errors
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
}]
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
|
|
672
1013
|
// ── Rendering ─────────────────────────────────────────────────────────────────
|
|
673
1014
|
|
|
674
1015
|
function printDomain(domain, results, verbose) {
|
|
@@ -831,16 +1172,22 @@ function buildScriptsDomain(root) {
|
|
|
831
1172
|
|
|
832
1173
|
// ── Domain selection ──────────────────────────────────────────────────────────
|
|
833
1174
|
|
|
1175
|
+
const DOMAIN_NAME_MAP = {
|
|
1176
|
+
ai: 'AI Instructions',
|
|
1177
|
+
cms: 'CMS Schema',
|
|
1178
|
+
'cms-mapping': 'CMS Mapping',
|
|
1179
|
+
scripts: 'Build Scripts',
|
|
1180
|
+
actions: 'Actions',
|
|
1181
|
+
sections: 'Sections'
|
|
1182
|
+
};
|
|
834
1183
|
function selectDomains(root, filter) {
|
|
835
|
-
const all = [buildAiInstructionsDomain(root), buildCmsSchemaDomain(root), buildActionsDomain(root), buildScriptsDomain(root)];
|
|
836
|
-
if (!filter)
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
};
|
|
843
|
-
return all.filter(d => d.name === map[filter]);
|
|
1184
|
+
const all = [buildAiInstructionsDomain(root), buildCmsSchemaDomain(root), buildCmsMappingDomain(root), buildActionsDomain(root), buildScriptsDomain(root), buildSectionsDomain(root)];
|
|
1185
|
+
if (!filter) {
|
|
1186
|
+
return all;
|
|
1187
|
+
}
|
|
1188
|
+
const filters = Array.isArray(filter) ? filter : [filter];
|
|
1189
|
+
const names = new Set(filters.map(f => DOMAIN_NAME_MAP[f]));
|
|
1190
|
+
return all.filter(d => names.has(d.name));
|
|
844
1191
|
}
|
|
845
1192
|
|
|
846
1193
|
// ── Core runner ───────────────────────────────────────────────────────────────
|
|
@@ -861,7 +1208,9 @@ function runDomains(domains, verbose, format) {
|
|
|
861
1208
|
} else {
|
|
862
1209
|
domainOk = printDomain(domain, results, verbose);
|
|
863
1210
|
}
|
|
864
|
-
if (!domainOk)
|
|
1211
|
+
if (!domainOk) {
|
|
1212
|
+
hasErrors = true;
|
|
1213
|
+
}
|
|
865
1214
|
}
|
|
866
1215
|
return {
|
|
867
1216
|
ok: !hasErrors,
|
|
@@ -872,11 +1221,12 @@ function runDomains(domains, verbose, format) {
|
|
|
872
1221
|
// ── Programmatic API ─────────────────────────────────────────────────────────
|
|
873
1222
|
|
|
874
1223
|
/**
|
|
875
|
-
* Runs
|
|
1224
|
+
* Runs validation domains against the given project root.
|
|
1225
|
+
* Pass `filters` to validate only specific domains; omit to validate all.
|
|
876
1226
|
* Prints results in slim mode and returns true if everything passes.
|
|
877
1227
|
*/
|
|
878
|
-
function runValidation(root) {
|
|
879
|
-
const domains = selectDomains(root);
|
|
1228
|
+
function runValidation(root, filters) {
|
|
1229
|
+
const domains = selectDomains(root, filters);
|
|
880
1230
|
const {
|
|
881
1231
|
ok
|
|
882
1232
|
} = runDomains(domains, false, 'text');
|
|
@@ -886,14 +1236,16 @@ function runValidation(root) {
|
|
|
886
1236
|
// ── Watch mode ────────────────────────────────────────────────────────────────
|
|
887
1237
|
|
|
888
1238
|
function startWatch(root, run) {
|
|
889
|
-
const watchDirs = [path.join(root, 'src', 'configuration'), path.join(root, 'src', 'actions')].filter(d => (0, _fs.existsSync)(d));
|
|
1239
|
+
const watchDirs = [path.join(root, 'src', 'configuration'), path.join(root, 'src', 'actions'), path.join(root, 'src', 'components', 'sections'), path.join(root, 'src', 'createRegistry.ts')].filter(d => (0, _fs.existsSync)(d));
|
|
890
1240
|
if (watchDirs.length === 0) {
|
|
891
1241
|
(0, _print.error)('No directories to watch found.');
|
|
892
1242
|
return;
|
|
893
1243
|
}
|
|
894
1244
|
let debounce = null;
|
|
895
1245
|
const trigger = () => {
|
|
896
|
-
if (debounce)
|
|
1246
|
+
if (debounce) {
|
|
1247
|
+
clearTimeout(debounce);
|
|
1248
|
+
}
|
|
897
1249
|
debounce = setTimeout(() => {
|
|
898
1250
|
console.clear();
|
|
899
1251
|
(0, _print.info)(`[${new Date().toLocaleTimeString()}] Re-validating...`);
|
|
@@ -913,7 +1265,7 @@ function startWatch(root, run) {
|
|
|
913
1265
|
|
|
914
1266
|
// ── Command ───────────────────────────────────────────────────────────────────
|
|
915
1267
|
|
|
916
|
-
const validateCommand = exports.validateCommand = new _commander.Command('validate').description('Validate project config files against their schemas').option('--verbose', 'Show all checks, including passing ones').option('--domain <domain>', 'Only validate one domain: ai, cms, actions, or
|
|
1268
|
+
const validateCommand = exports.validateCommand = new _commander.Command('validate').description('Validate project config files against their schemas').option('--verbose', 'Show all checks, including passing ones').option('--domain <domain>', 'Only validate one domain: ai, cms, actions, scripts, or sections').option('--format <format>', 'Output format: text (default) or json', 'text').option('--watch', 'Re-validate on file changes (TTY only)').option('--strict', 'Exit with error even on warnings').option('--project <path>', 'Explicit project root (overrides cwd auto-detection)').action(opts => {
|
|
917
1269
|
const verbose = Boolean(opts.verbose);
|
|
918
1270
|
const format = opts.format ?? 'text';
|
|
919
1271
|
const domainFilter = opts.domain;
|