intentcss-cli 0.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/LICENSE +21 -0
- package/README.md +21 -0
- package/dist/bin/intent.d.ts +8 -0
- package/dist/bin/intent.d.ts.map +1 -0
- package/dist/bin/intent.js +55 -0
- package/dist/bin/intent.js.map +1 -0
- package/dist/commands/compile.d.ts +14 -0
- package/dist/commands/compile.d.ts.map +1 -0
- package/dist/commands/compile.js +103 -0
- package/dist/commands/compile.js.map +1 -0
- package/dist/commands/generate.d.ts +14 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +127 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/init.d.ts +12 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +398 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/migrate.d.ts +13 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +155 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/validate.d.ts +13 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +109 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/config.d.ts +9 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +46 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/diagnostics.d.ts +7 -0
- package/dist/utils/diagnostics.d.ts.map +1 -0
- package/dist/utils/diagnostics.js +9 -0
- package/dist/utils/diagnostics.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate Command
|
|
3
|
+
*
|
|
4
|
+
* Validates component usage against the design system schema.
|
|
5
|
+
*/
|
|
6
|
+
import fs from 'node:fs/promises';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import { globby } from 'globby';
|
|
9
|
+
import { parseFiles, validateAllUsages } from 'intent-core';
|
|
10
|
+
import { loadConfig } from '../utils/config.js';
|
|
11
|
+
export async function validateCommand(files, options) {
|
|
12
|
+
console.log(chalk.blue('Intent'), chalk.gray('validating...\n'));
|
|
13
|
+
const startTime = Date.now();
|
|
14
|
+
try {
|
|
15
|
+
// Load configuration
|
|
16
|
+
const config = await loadConfig(options.config);
|
|
17
|
+
// Find files to validate
|
|
18
|
+
const patterns = files.length > 0
|
|
19
|
+
? files
|
|
20
|
+
: ['src/**/*.{tsx,jsx,vue,svelte}'];
|
|
21
|
+
const filePaths = await globby(patterns, { absolute: true });
|
|
22
|
+
if (filePaths.length === 0) {
|
|
23
|
+
console.log(chalk.yellow('No files found to validate'));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
console.log(`Found ${chalk.cyan(filePaths.length)} files to validate\n`);
|
|
27
|
+
// Read and parse files
|
|
28
|
+
const parsedFiles = [];
|
|
29
|
+
for (const filePath of filePaths) {
|
|
30
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
31
|
+
parsedFiles.push({ path: filePath, content });
|
|
32
|
+
}
|
|
33
|
+
// Parse for Intent component usage
|
|
34
|
+
const parseOptions = {
|
|
35
|
+
intentImports: ['intent-react', 'intent'],
|
|
36
|
+
componentNames: Object.keys(config.components),
|
|
37
|
+
};
|
|
38
|
+
const parsedResults = parseFiles(parsedFiles.map(f => ({ path: f.path, content: f.content })), parseOptions);
|
|
39
|
+
// Collect all usages
|
|
40
|
+
const batchUsages = [];
|
|
41
|
+
for (const [filePath, result] of Object.entries(parsedResults)) {
|
|
42
|
+
if (result.usages.length > 0) {
|
|
43
|
+
batchUsages.push({ file: filePath, usages: result.usages });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
console.log(`Found ${chalk.cyan(batchUsages.reduce((sum, b) => sum + b.usages.length, 0))} Intent component usages\n`);
|
|
47
|
+
// Validate
|
|
48
|
+
const validationResult = validateAllUsages(config, batchUsages, { strict: options.strict });
|
|
49
|
+
// Report results
|
|
50
|
+
const duration = Date.now() - startTime;
|
|
51
|
+
if (validationResult.valid && validationResult.issues.length === 0) {
|
|
52
|
+
console.log(chalk.green('✓'), 'All validations passed');
|
|
53
|
+
console.log(chalk.gray(` ${duration}ms`));
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// Group issues by file
|
|
57
|
+
const issuesByFile = new Map();
|
|
58
|
+
for (const issue of validationResult.issues) {
|
|
59
|
+
const file = issue.path.split(':')[0];
|
|
60
|
+
if (!issuesByFile.has(file)) {
|
|
61
|
+
issuesByFile.set(file, []);
|
|
62
|
+
}
|
|
63
|
+
issuesByFile.get(file).push(issue);
|
|
64
|
+
}
|
|
65
|
+
// Print issues
|
|
66
|
+
for (const [file, issues] of issuesByFile) {
|
|
67
|
+
console.log(chalk.underline(file));
|
|
68
|
+
for (const issue of issues) {
|
|
69
|
+
const icon = issue.severity === 'error' ? chalk.red('✗') : chalk.yellow('⚠');
|
|
70
|
+
const code = chalk.gray(`[${issue.code}]`);
|
|
71
|
+
const location = issue.path.includes(':')
|
|
72
|
+
? chalk.gray(issue.path.split(':').slice(1).join(':'))
|
|
73
|
+
: '';
|
|
74
|
+
console.log(` ${icon} ${issue.message} ${code}`);
|
|
75
|
+
if (location) {
|
|
76
|
+
console.log(` ${chalk.gray('at')} ${location}`);
|
|
77
|
+
}
|
|
78
|
+
if (issue.suggestion) {
|
|
79
|
+
console.log(` ${chalk.cyan('→')} ${issue.suggestion}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
console.log();
|
|
83
|
+
}
|
|
84
|
+
// Summary
|
|
85
|
+
const errors = validationResult.issues.filter(i => i.severity === 'error').length;
|
|
86
|
+
const warnings = validationResult.issues.filter(i => i.severity === 'warning').length;
|
|
87
|
+
console.log(chalk.gray('─'.repeat(50)));
|
|
88
|
+
if (errors > 0) {
|
|
89
|
+
console.log(chalk.red(`${errors} error${errors === 1 ? '' : 's'}`));
|
|
90
|
+
}
|
|
91
|
+
if (warnings > 0) {
|
|
92
|
+
console.log(chalk.yellow(`${warnings} warning${warnings === 1 ? '' : 's'}`));
|
|
93
|
+
}
|
|
94
|
+
console.log(chalk.gray(`${duration}ms`));
|
|
95
|
+
if (!validationResult.valid) {
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Auto-fix if requested
|
|
100
|
+
if (options.fix) {
|
|
101
|
+
console.log(chalk.gray('\nAuto-fix not yet implemented'));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
console.error(chalk.red('Error:'), error instanceof Error ? error.message : error);
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAElC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAuB,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAQhD,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,KAAe,EACf,OAAwB;IAExB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAEjE,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,IAAI,CAAC;QACH,qBAAqB;QACrB,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,MAAM,CA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gBAC5B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;QAED,wBAAwB;QACxB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YAChB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACnF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intent CLI
|
|
3
|
+
*
|
|
4
|
+
* Programmatic API for the Intent CLI.
|
|
5
|
+
*/
|
|
6
|
+
export { compileCommand } from './commands/compile.js';
|
|
7
|
+
export { validateCommand } from './commands/validate.js';
|
|
8
|
+
export { initCommand } from './commands/init.js';
|
|
9
|
+
export { migrateCommand } from './commands/migrate.js';
|
|
10
|
+
export { generateCommand } from './commands/generate.js';
|
|
11
|
+
export { loadConfig } from './utils/config.js';
|
|
12
|
+
export { formatDiagnostics } from './utils/diagnostics.js';
|
|
13
|
+
export declare const VERSION = "0.1.0";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intent CLI
|
|
3
|
+
*
|
|
4
|
+
* Programmatic API for the Intent CLI.
|
|
5
|
+
*/
|
|
6
|
+
export { compileCommand } from './commands/compile.js';
|
|
7
|
+
export { validateCommand } from './commands/validate.js';
|
|
8
|
+
export { initCommand } from './commands/init.js';
|
|
9
|
+
export { migrateCommand } from './commands/migrate.js';
|
|
10
|
+
export { generateCommand } from './commands/generate.js';
|
|
11
|
+
export { loadConfig } from './utils/config.js';
|
|
12
|
+
export { formatDiagnostics } from './utils/diagnostics.js';
|
|
13
|
+
export const VERSION = '0.1.0';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config Loader
|
|
3
|
+
*
|
|
4
|
+
* Loads and parses intent.config.ts files using jiti for runtime TS support.
|
|
5
|
+
*/
|
|
6
|
+
import type { DesignSystemConfig } from 'intent-core';
|
|
7
|
+
export declare function loadConfigSync(configPath: string): DesignSystemConfig;
|
|
8
|
+
export declare function loadConfig(configPath: string): Promise<DesignSystemConfig>;
|
|
9
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAItD,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB,CA4BrE;AAED,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAGhF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config Loader
|
|
3
|
+
*
|
|
4
|
+
* Loads and parses intent.config.ts files using jiti for runtime TS support.
|
|
5
|
+
*/
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
9
|
+
export function loadConfigSync(configPath) {
|
|
10
|
+
const absolutePath = path.resolve(configPath);
|
|
11
|
+
// Try jiti first (fast, handles TS well)
|
|
12
|
+
try {
|
|
13
|
+
const jiti = require('jiti')(import.meta.url, { interopDefault: true });
|
|
14
|
+
const imported = jiti(absolutePath);
|
|
15
|
+
const config = imported?.default || imported;
|
|
16
|
+
if (isValidConfig(config))
|
|
17
|
+
return config;
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
const errMsg = error.message;
|
|
21
|
+
// Check if jiti is not installed
|
|
22
|
+
if (errMsg.includes('Cannot find module') && errMsg.includes('jiti')) {
|
|
23
|
+
throw new Error(`jiti is required to load TypeScript config files.\n\n` +
|
|
24
|
+
`Please install it:\n` +
|
|
25
|
+
` npm install -D jiti\n\n` +
|
|
26
|
+
`Or use a JavaScript config file:\n` +
|
|
27
|
+
` intent.config.js`);
|
|
28
|
+
}
|
|
29
|
+
// Other error - rethrow with context
|
|
30
|
+
throw new Error(`Failed to load config: ${errMsg}`);
|
|
31
|
+
}
|
|
32
|
+
throw new Error('Config loader failed');
|
|
33
|
+
}
|
|
34
|
+
export async function loadConfig(configPath) {
|
|
35
|
+
// For now, use sync version since jiti is synchronous
|
|
36
|
+
return loadConfigSync(configPath);
|
|
37
|
+
}
|
|
38
|
+
function isValidConfig(config) {
|
|
39
|
+
return (typeof config === 'object' &&
|
|
40
|
+
config !== null &&
|
|
41
|
+
'name' in config &&
|
|
42
|
+
typeof config.name === 'string' &&
|
|
43
|
+
'tokens' in config &&
|
|
44
|
+
'components' in config);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,MAAM,UAAU,cAAc,CAAC,UAAkB;IAC/C,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAE9C,yCAAyC;IACzC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC;QACxE,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,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agnostics.js","sourceRoot":"","sources":["../../src/utils/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,UAAU,iBAAiB,CAAC,WAAqB;IACrD,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACnD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "intentcss-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI tools for Intent styling framework",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/mixedmetals/intent-framework",
|
|
10
|
+
"directory": "packages/cli"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"intent",
|
|
14
|
+
"cli",
|
|
15
|
+
"css",
|
|
16
|
+
"design-system",
|
|
17
|
+
"compiler"
|
|
18
|
+
],
|
|
19
|
+
"bin": {
|
|
20
|
+
"intent": "./dist/bin/intent.js"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc",
|
|
37
|
+
"dev": "tsc --watch",
|
|
38
|
+
"test": "vitest run --passWithNoTests",
|
|
39
|
+
"clean": "rm -rf dist"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"intent-core": "workspace:^",
|
|
43
|
+
"commander": "^11.0.0",
|
|
44
|
+
"chalk": "^5.3.0",
|
|
45
|
+
"globby": "^14.0.0",
|
|
46
|
+
"chokidar": "^3.5.3",
|
|
47
|
+
"jiti": "^1.21.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^20.10.0",
|
|
51
|
+
"typescript": "^5.3.0"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=18.0.0"
|
|
55
|
+
}
|
|
56
|
+
}
|