@ngcorex/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.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @ngcorex/cli
2
2
 
3
+ ![NPM Version](https://img.shields.io/npm/v/%40ngcorex%2Fcli?style=flat-square&logo=npm&labelColor=%23D50100&color=%23000) ![NPM License](https://img.shields.io/npm/l/%40ngcorex%2Fcli?style=flat-square) ![Static Badge](https://img.shields.io/badge/Github-Repo-blue?style=flat-square&logo=github) ![NPM Downloads](https://img.shields.io/npm/dm/%40ngcorex%2Fcli?style=flat-square&logo=npm&logoColor=%23ffffff&labelColor=%23D50100&color=%23000)
4
+
3
5
  Command-line interface for **ngCorex**.
4
6
 
5
7
  This package provides the `ngcorex` CLI used to build CSS from an
@@ -37,6 +39,23 @@ npm install -D @ngcorex/cli
37
39
 
38
40
  > The CLI depends on `@ngcorex/css`, which will be installed automatically.
39
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
+
40
59
  ### Create tokens.json
41
60
 
42
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
+ }
@@ -5,6 +5,7 @@ import { loadConfig } from '../config/load-config.js';
5
5
  import { writeCss } from '../output/write-css.js';
6
6
  import { buildCssFromConfig } from '@ngcorex/css';
7
7
  import { resolve } from 'node:path';
8
+ let hasShownInlineTokenNotice = false;
8
9
  export async function runBuild(options = {}) {
9
10
  const configPath = resolveConfigPath();
10
11
  const config = await loadConfig(configPath);
@@ -134,6 +135,15 @@ export async function runBuild(options = {}) {
134
135
  tokens: fileTokens
135
136
  }
136
137
  : config;
138
+ if (!fileTokens &&
139
+ config.tokens &&
140
+ !hasShownInlineTokenNotice) {
141
+ console.info('');
142
+ console.info('ℹ️ Inline tokens detected.');
143
+ console.info(' Using tokens.json is recommended for larger or shared projects.');
144
+ console.info('');
145
+ hasShownInlineTokenNotice = true;
146
+ }
137
147
  const css = buildCssFromConfig(effectiveConfig);
138
148
  console.log('✔ Generated CSS');
139
149
  writeCss(outputPath, css, { dryRun: options.dryRun });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngcorex/cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "CLI for ngCorex - Angular-native design token engine",
5
5
  "keywords": [
6
6
  "design-tokens",
@@ -30,5 +30,12 @@
30
30
  ],
31
31
  "scripts": {
32
32
  "build": "tsc -p tsconfig.json"
33
- }
33
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/arkdezin/ngCorex.git",
37
+ "directory": "packages/cli"
38
+ },
39
+
40
+ "homepage": "https://github.com/arkdezin/ngCorex"
34
41
  }