@aliens-syndicate/cli 0.1.2 → 0.1.4
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.es-ES.md +53 -10
- package/README.md +53 -10
- package/README.pt-BR.md +53 -10
- package/README.zh-CN.md +53 -10
- package/package.json +6 -1
- package/tools/build.mjs +372 -36
- package/tools/cache.mjs +41 -0
- package/tools/cli-shared.mjs +237 -0
- package/tools/cli.mjs +145 -48
- package/tools/create.mjs +207 -78
- package/tools/doctor.mjs +139 -0
- package/tools/generate.mjs +175 -0
- package/tools/icon-docs.mjs +132 -0
- package/tools/project-layout.mjs +3 -3
- package/tools/runtime.mjs +216 -8
- package/tools/serve.mjs +152 -0
- package/tools/starter/ai/agents/codingbot.agent +5 -0
- package/tools/starter/ai/rules/architecture.rule +12 -0
- package/tools/starter/ai/skills/create-element.skill +7 -0
- package/tools/starter/app/elements/molecules/kit-card-link/kit-card-link.markup +0 -2
- package/tools/starter/app/pages/kit-overview/kit-overview.markup +6 -6
- package/tools/starter/app/pages/style-guide/style-guide.style +57 -57
- package/tools/starter/styles/components/alerts.style +6 -5
- package/tools/starter/styles/components/badges.style +6 -5
- package/tools/starter/styles/components/borders.style +2 -1
- package/tools/starter/styles/components/buttons.style +14 -13
- package/tools/starter/styles/components/cards.style +1 -1
- package/tools/starter/styles/components/feedback.style +3 -2
- package/tools/starter/styles/components/forms.style +5 -4
- package/tools/starter/styles/components/tables.style +4 -3
- package/tools/starter/styles/components/typography.style +6 -5
- package/tools/starter/styles/generic/ui-base.style +1 -1
- package/tools/starter/styles/objects/ui-layout.style +1 -1
- package/tools/style-docs.mjs +274 -0
- package/tools/update.mjs +110 -0
- package/tools/vscode-space/package.json +5 -8
- package/tools/vscode-space/space.tmLanguage.json +1 -1
- package/tools/vscode-space/syntax.cjs +103 -62
- package/tools/watch.mjs +48 -0
|
@@ -1,46 +1,61 @@
|
|
|
1
1
|
const { findColors } = require('./style-colors.cjs');
|
|
2
2
|
|
|
3
3
|
const reserved = new Map([
|
|
4
|
-
['signal',
|
|
5
|
-
['effect',
|
|
6
|
-
['returns',
|
|
7
|
-
['import',
|
|
8
|
-
['onInit',
|
|
9
|
-
['onDestroy',
|
|
10
|
-
['if',
|
|
11
|
-
['
|
|
12
|
-
['
|
|
13
|
-
['
|
|
4
|
+
['signal', 'spaceReactive'], ['computed', 'spaceReactive'],
|
|
5
|
+
['effect', 'spaceReactive'], ['actions', 'spaceActions'],
|
|
6
|
+
['returns', 'spaceReturn'], ['return', 'spaceReturn'],
|
|
7
|
+
['import', 'keyword'], ['body', 'keyword'],
|
|
8
|
+
['onInit', 'keyword'], ['onMount', 'keyword'],
|
|
9
|
+
['onDestroy', 'keyword'], ['function', 'keyword'],
|
|
10
|
+
['if', 'keyword'], ['else', 'keyword'],
|
|
11
|
+
['for', 'keyword'], ['list', 'keyword'],
|
|
12
|
+
['number', 'type'], ['integer', 'type'], ['string', 'type'],
|
|
13
|
+
['boolean', 'type'], ['void', 'type'],
|
|
14
|
+
['true', 'spaceLiteral'], ['false', 'spaceLiteral'], ['null', 'spaceLiteral']
|
|
14
15
|
]);
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
'
|
|
20
|
-
|
|
17
|
+
// Each token type belongs to one color role. The editor colors a type with its rule in package.json, and the site
|
|
18
|
+
// highlights with a space-<role> class whose color the build reads from those same rules, so both always match.
|
|
19
|
+
const roles = {
|
|
20
|
+
keyword: 'control', class: 'type', type: 'type', function: 'action', spaceActions: 'action', spaceElement: 'action',
|
|
21
|
+
property: 'value', variable: 'value', number: 'return', string: 'return', spaceReturn: 'return',
|
|
22
|
+
spaceLiteral: 'return', spaceTranslation: 'return', spaceReactive: 'reactive', spaceSelector: 'reactive',
|
|
23
|
+
comment: 'comment'
|
|
24
|
+
};
|
|
25
|
+
const tokenTypes = Object.keys(roles);
|
|
26
|
+
|
|
27
|
+
const htmlTags = new Set(('a abbr address article aside audio b blockquote body br button canvas caption cite code col ' +
|
|
28
|
+
'colgroup data datalist dd del details dfn dialog div dl dt em fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 ' +
|
|
29
|
+
'head header hgroup hr html i iframe img input ins kbd label legend li link main mark menu meter nav noscript object ol ' +
|
|
30
|
+
'optgroup option output p picture pre progress q rp rt ruby s samp search section select slot small source span strong ' +
|
|
31
|
+
'sub summary sup svg table tbody td template textarea tfoot th thead time tr track u ul var video wbr').split(' '));
|
|
32
|
+
|
|
33
|
+
// Each part of a selector takes the color of its kind: the markup id or variant ("site-header"), its _modifier
|
|
34
|
+
// ("_menu-open") and [attribute] filters, HTML tags ("li", "*"), and :states (":hover", "::before", ":nth-child(2)").
|
|
35
|
+
// Combinators, commas and parentheses stay uncolored.
|
|
36
|
+
const selectorPart = /\[[^\]]*\]|:nth-[a-z-]+\([^)]*\)|::?[A-Za-z-]+|_[A-Za-z0-9-]+|[A-Za-z][A-Za-z0-9-]*|\*/g;
|
|
37
|
+
|
|
38
|
+
function selectorType(part) {
|
|
39
|
+
if (part.startsWith('[') || part.startsWith('_')) return 'string';
|
|
40
|
+
if (part.startsWith(':')) return 'keyword';
|
|
41
|
+
if (part === '*' || htmlTags.has(part)) return 'spaceElement';
|
|
42
|
+
return 'spaceSelector';
|
|
43
|
+
}
|
|
21
44
|
|
|
22
45
|
function isSpaceComment(value, style) {
|
|
23
|
-
return value.startsWith('#') && (!style || /^#(?:\s|$|(?:AI|TODO|FIXME|NOTE|WARN|DEPRECATED)\b)/.test(value));
|
|
46
|
+
return value.startsWith('#') && (!style || /^#(?:\s|$|(?:AGENT|AI|TODO|FIXME|NOTE|WARN|DEPRECATED)\b)/.test(value));
|
|
24
47
|
}
|
|
25
48
|
|
|
26
49
|
function lexicalType(value) {
|
|
27
50
|
if (reserved.has(value)) return reserved.get(value);
|
|
28
|
-
if (value.startsWith('/*')) return
|
|
29
|
-
if (value.startsWith('@')) return
|
|
30
|
-
if (value.startsWith('$')) return
|
|
31
|
-
if (/^["']/.test(value)) return
|
|
32
|
-
if (/^\d/.test(value)) return
|
|
51
|
+
if (value.startsWith('/*')) return 'comment';
|
|
52
|
+
if (value.startsWith('@')) return 'spaceTranslation';
|
|
53
|
+
if (value.startsWith('$')) return 'variable';
|
|
54
|
+
if (/^["']/.test(value)) return 'string';
|
|
55
|
+
if (/^\d/.test(value)) return 'number';
|
|
33
56
|
return null;
|
|
34
57
|
}
|
|
35
58
|
|
|
36
|
-
function styleValueType(token, rest) {
|
|
37
|
-
if (token.startsWith('/*')) return ['comment', 'comment'];
|
|
38
|
-
if (token.startsWith('--')) return ['variable', 'value'];
|
|
39
|
-
if (/^\d/.test(token)) return ['number', 'return'];
|
|
40
|
-
if (rest.startsWith('(')) return ['function', 'action'];
|
|
41
|
-
return ['string', 'return'];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
59
|
function analyzeSpace(source, extension) {
|
|
45
60
|
const tokens = [];
|
|
46
61
|
const colors = [];
|
|
@@ -52,12 +67,12 @@ function analyzeSpace(source, extension) {
|
|
|
52
67
|
const body = text.trim();
|
|
53
68
|
if (!body) continue;
|
|
54
69
|
const indent = text.length - text.trimStart().length;
|
|
55
|
-
const emit = (start, length, type,
|
|
56
|
-
tokens.push({ line, start, length, type, role, declaration });
|
|
70
|
+
const emit = (start, length, type, declaration = false) => {
|
|
71
|
+
tokens.push({ line, start, length, type, role: roles[type], declaration });
|
|
57
72
|
};
|
|
58
73
|
|
|
59
74
|
if (isSpaceComment(body, style)) {
|
|
60
|
-
emit(indent, body.length, 'comment'
|
|
75
|
+
emit(indent, body.length, 'comment');
|
|
61
76
|
continue;
|
|
62
77
|
}
|
|
63
78
|
|
|
@@ -65,58 +80,84 @@ function analyzeSpace(source, extension) {
|
|
|
65
80
|
const parent = parents.at(-1)?.kind;
|
|
66
81
|
const header = indent === 0 && /^([A-Z][a-z]+)( +)([A-Z][\w]*)$/.exec(body);
|
|
67
82
|
if (header && '.' + header[1].toLowerCase() === extension) {
|
|
68
|
-
emit(0, header[1].length, 'keyword'
|
|
69
|
-
emit(header[1].length + header[2].length, header[3].length, 'class',
|
|
83
|
+
emit(0, header[1].length, 'keyword');
|
|
84
|
+
emit(header[1].length + header[2].length, header[3].length, 'class', true);
|
|
70
85
|
parents.push({ indent, kind: 'header' });
|
|
71
86
|
continue;
|
|
72
87
|
}
|
|
73
88
|
|
|
74
|
-
|
|
75
|
-
|
|
89
|
+
// A .style reads in three colors: the selector (the markup id or variant being styled), the style itself
|
|
90
|
+
// (utilities and "property: value" declarations alike) and the variants or at-rules that say when it applies.
|
|
76
91
|
if (style) {
|
|
77
|
-
const property = parent === 'selector' && /^([\w-]
|
|
92
|
+
const property = parent === 'selector' && /^(-{0,2}[A-Za-z][\w-]*):\s+/.exec(body);
|
|
78
93
|
if (property) {
|
|
79
|
-
emit(indent, property[1].length, 'property'
|
|
80
|
-
valueStart = indent + property[0].length;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
emit(
|
|
94
|
+
emit(indent, property[1].length, 'property');
|
|
95
|
+
const valueStart = indent + property[0].length;
|
|
96
|
+
colors.push(...findColors(text.slice(valueStart), property[1])
|
|
97
|
+
.map(color => ({ ...color, line, start: valueStart + color.start })));
|
|
98
|
+
const words = /\/\*[^]*?\*\/|\S+/g;
|
|
99
|
+
words.lastIndex = valueStart;
|
|
100
|
+
for (let match = words.exec(text); match; match = words.exec(text)) {
|
|
101
|
+
emit(match.index, match[0].length, match[0].startsWith('/*') ? 'comment' : 'property');
|
|
87
102
|
}
|
|
88
|
-
parents.push({ indent, kind });
|
|
103
|
+
parents.push({ indent, kind: 'node' });
|
|
89
104
|
continue;
|
|
90
105
|
}
|
|
106
|
+
// Any other line inside a selector lists utilities, like "flex gap-4 md:flex-row": the variants before
|
|
107
|
+
// the last ":" read as keywords and the utility as a property.
|
|
108
|
+
if (parent === 'selector') {
|
|
109
|
+
const utilities = /\S+/g;
|
|
110
|
+
for (let match = utilities.exec(text); match; match = utilities.exec(text)) {
|
|
111
|
+
const token = match[0];
|
|
112
|
+
let depth = 0;
|
|
113
|
+
let split = -1;
|
|
114
|
+
for (let index = 0; index < token.length; index++) {
|
|
115
|
+
if ('[('.includes(token[index])) depth++;
|
|
116
|
+
else if ('])'.includes(token[index])) depth--;
|
|
117
|
+
else if (token[index] === ':' && depth === 0) split = index;
|
|
118
|
+
}
|
|
119
|
+
if (split >= 0) emit(match.index, split + 1, 'keyword');
|
|
120
|
+
emit(match.index + split + 1, token.length - split - 1, 'property');
|
|
121
|
+
}
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const kind = body.startsWith('@') ? 'atRule' : /^(?:default|import):$/.test(body) ? 'manifest' : 'selector';
|
|
125
|
+
if (kind === 'selector' && parent !== 'manifest') {
|
|
126
|
+
selectorPart.lastIndex = indent;
|
|
127
|
+
for (let match = selectorPart.exec(text); match; match = selectorPart.exec(text)) {
|
|
128
|
+
emit(match.index, match[0].length, selectorType(match[0]));
|
|
129
|
+
}
|
|
130
|
+
} else if (parent !== 'manifest') emit(indent, body.length, 'keyword');
|
|
131
|
+
parents.push({ indent, kind });
|
|
132
|
+
continue;
|
|
91
133
|
}
|
|
92
134
|
|
|
93
|
-
const
|
|
135
|
+
const loop = markup && /^for\s/.test(body);
|
|
136
|
+
const element = markup && !loop && /^[a-z][\w-]*/.exec(body)?.[0];
|
|
94
137
|
const signal = /^signal\s+(\w+):/.exec(body)?.[1];
|
|
95
138
|
const action = parent === 'actions' && /^(\w+):$/.exec(body)?.[1];
|
|
96
139
|
const callable = /^function\s+(\w+)\(/.exec(body)?.[1];
|
|
97
|
-
const field = parent && !
|
|
98
|
-
const
|
|
99
|
-
const lexemes = value.matchAll(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\/\*[^]*?\*\/|--[A-Za-z_][\w-]*|[@$][a-zA-Z_][\w.-]*|\b[A-Za-z_-][\w-]*\b|\b\d+(?:\.\d+)?\b/g);
|
|
140
|
+
const field = parent && !markup && /^(\w[\w-]*):/.exec(body)?.[1];
|
|
141
|
+
const lexemes = text.matchAll(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\/\*[^]*?\*\/|--[A-Za-z_][\w-]*|[@$][a-zA-Z_][\w.-]*|\b[A-Za-z_-][\w-]*\b|\b\d+(?:\.\d+)?\b/g);
|
|
100
142
|
for (const match of lexemes) {
|
|
101
143
|
const token = match[0];
|
|
102
|
-
const start =
|
|
144
|
+
const start = match.index;
|
|
103
145
|
const rest = text.slice(start + token.length);
|
|
104
|
-
|
|
105
|
-
let type = style ? styleValueType(token, rest) : lexicalType(token);
|
|
146
|
+
let type = lexicalType(token);
|
|
106
147
|
let declaration = false;
|
|
107
|
-
if (start === indent && token === element) type =
|
|
108
|
-
else if (
|
|
109
|
-
else if (
|
|
110
|
-
else if (token ===
|
|
111
|
-
else if (
|
|
112
|
-
else if (!type &&
|
|
113
|
-
if (type
|
|
148
|
+
if (start === indent && token === element) type = 'spaceElement';
|
|
149
|
+
else if (loop && token === 'in') type = 'keyword';
|
|
150
|
+
else if (markup && /^\s*=/.test(rest) && /^[a-z][\w-]*$/.test(token)) type = 'property';
|
|
151
|
+
else if (token === signal) { type = 'variable'; declaration = true; }
|
|
152
|
+
else if (token === action || token === callable) { type = 'function'; declaration = true; }
|
|
153
|
+
else if (!type && !markup && text.slice(0, start).endsWith('this.')) type = 'property';
|
|
154
|
+
else if (!type && start === indent && token === field) type = 'property';
|
|
155
|
+
if (type) emit(start, token.length, type, declaration);
|
|
114
156
|
}
|
|
115
|
-
for (const color of lineColors) emit(valueStart + color.start, color.length, 'spaceColor', 'return');
|
|
116
157
|
parents.push({ indent, kind: body === 'actions:' ? 'actions' : 'node' });
|
|
117
158
|
}
|
|
118
159
|
|
|
119
160
|
return { tokens: tokens.sort((left, right) => left.line - right.line || left.start - right.start), colors };
|
|
120
161
|
}
|
|
121
162
|
|
|
122
|
-
module.exports = { analyzeSpace, isSpaceComment, tokenTypes };
|
|
163
|
+
module.exports = { analyzeSpace, htmlTags, isSpaceComment, roles, tokenTypes };
|
package/tools/watch.mjs
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { watch } from 'node:fs';
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import { join, resolve, sep } from 'node:path';
|
|
4
|
+
|
|
5
|
+
// Watch mode: every saved file runs the build again, so dist/ and ai/.map always describe the current code.
|
|
6
|
+
const language = (() => {
|
|
7
|
+
const tag = (process.env.ALIENS_LANG || process.env.LC_ALL || process.env.LC_MESSAGES || process.env.LANG ||
|
|
8
|
+
Intl.DateTimeFormat().resolvedOptions().locale || 'en').toLowerCase();
|
|
9
|
+
return ['pt', 'es', 'zh'].find(code => tag.startsWith(code)) ?? 'en';
|
|
10
|
+
})();
|
|
11
|
+
const watching = {
|
|
12
|
+
en: 'Watching the project. Each saved file rebuilds dist/ and ai/.map (Ctrl+C to stop).',
|
|
13
|
+
pt: 'Observando o projeto. Cada arquivo salvo refaz dist/ e ai/.map (Ctrl+C para parar).',
|
|
14
|
+
es: 'Observando el proyecto. Cada archivo guardado rehace dist/ y ai/.map (Ctrl+C para detener).',
|
|
15
|
+
zh: '正在监听项目。每次保存文件都会重新生成 dist/ 和 ai/.map(按 Ctrl+C 停止)。'
|
|
16
|
+
}[language];
|
|
17
|
+
|
|
18
|
+
const workspace = resolve(import.meta.dirname, '..');
|
|
19
|
+
const build = join(import.meta.dirname, 'build.mjs');
|
|
20
|
+
// The build writes dist/ and the .map itself, so those changes never start another build.
|
|
21
|
+
const ignored = new Set(['dist', 'node_modules', '.git', '.DS_Store']);
|
|
22
|
+
const skip = file => file.split(sep).some(part => ignored.has(part)) || file.endsWith('.map');
|
|
23
|
+
|
|
24
|
+
let running = null;
|
|
25
|
+
let pending = false;
|
|
26
|
+
let timer;
|
|
27
|
+
function run() {
|
|
28
|
+
if (running) {
|
|
29
|
+
pending = true;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
running = spawn(process.execPath, ['--disable-warning=ExperimentalWarning', build], { stdio: 'inherit' });
|
|
33
|
+
running.on('exit', () => {
|
|
34
|
+
running = null;
|
|
35
|
+
if (pending) {
|
|
36
|
+
pending = false;
|
|
37
|
+
run();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
watch(workspace, { recursive: true }, (event, file) => {
|
|
43
|
+
if (!file || skip(file)) return;
|
|
44
|
+
clearTimeout(timer);
|
|
45
|
+
timer = setTimeout(run, 120);
|
|
46
|
+
});
|
|
47
|
+
console.log(watching);
|
|
48
|
+
run();
|