@ngcorex/cli 0.1.3 → 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.md CHANGED
@@ -39,6 +39,23 @@ npm install -D @ngcorex/cli
39
39
 
40
40
  > The CLI depends on `@ngcorex/css`, which will be installed automatically.
41
41
 
42
+ ### Initialize ngCorex
43
+
44
+ To quickly get started, run:
45
+
46
+ ```bash
47
+ ngcorex init
48
+ ```
49
+
50
+ This will create:
51
+
52
+ - `tokens.json`
53
+ - `ngcorex.config.ts`
54
+
55
+ If the files already exist, they will not be overwritten.
56
+
57
+ ***Or Create files manually:***
58
+
42
59
  ### Create tokens.json
43
60
 
44
61
  Create a `tokens.json` file at your project root:
@@ -1,5 +1,6 @@
1
1
  import { buildCommand } from './build.js';
2
2
  import { versionCommand } from './version.js';
3
+ import { initCommand } from './init.js';
3
4
  export async function runCommand(args) {
4
5
  const command = args[0];
5
6
  switch (command) {
@@ -11,6 +12,14 @@ export async function runCommand(args) {
11
12
  case '-v':
12
13
  await versionCommand();
13
14
  break;
15
+ case 'init': {
16
+ await initCommand();
17
+ return;
18
+ }
19
+ case '--help':
20
+ case '-h':
21
+ printHelp();
22
+ return;
14
23
  default:
15
24
  printHelp();
16
25
  }
@@ -20,6 +29,7 @@ function printHelp() {
20
29
  ngCorex CLI
21
30
 
22
31
  Usage:
32
+ ngcorex init Create starter config and tokens
23
33
  ngcorex build Generate CSS
24
34
  ngcorex build --watch
25
35
  ngcorex version Show version
@@ -0,0 +1,50 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ export async function initCommand() {
4
+ const cwd = process.cwd();
5
+ const tokensPath = path.resolve(cwd, 'tokens.json');
6
+ const configPath = path.resolve(cwd, 'ngcorex.config.ts');
7
+ let createdSomething = false;
8
+ // tokens.json
9
+ if (!fs.existsSync(tokensPath)) {
10
+ fs.writeFileSync(tokensPath, JSON.stringify({
11
+ spacing: {
12
+ "1": 4,
13
+ "2": 8
14
+ },
15
+ colors: {
16
+ gray: {
17
+ "100": "#f3f4f6",
18
+ "900": "#111827"
19
+ }
20
+ }
21
+ }, null, 2));
22
+ console.info('✔ Created tokens.json');
23
+ createdSomething = true;
24
+ }
25
+ else {
26
+ console.info('i tokens.json already exists — skipped');
27
+ }
28
+ // ngcorex.config.ts
29
+ if (!fs.existsSync(configPath)) {
30
+ fs.writeFileSync(configPath, `import { defineNgCorexConfig } from '@ngcorex/css';
31
+
32
+ export default defineNgCorexConfig({
33
+ output: {
34
+ file: 'src/styles/ngcorex.css'
35
+ }
36
+ });
37
+ `);
38
+ console.info('✔ Created ngcorex.config.ts');
39
+ createdSomething = true;
40
+ }
41
+ else {
42
+ console.info('i ngcorex.config.ts already exists — skipped');
43
+ }
44
+ if (createdSomething) {
45
+ console.info('');
46
+ console.info('Next steps:');
47
+ console.info('- Run `ngcorex build` to generate CSS');
48
+ console.info('- Edit tokens.json to customize your design tokens');
49
+ }
50
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngcorex/cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "CLI for ngCorex - Angular-native design token engine",
5
5
  "keywords": [
6
6
  "design-tokens",