@aakaar/cli 0.0.2 → 0.0.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/dist/index.cjs CHANGED
@@ -12,14 +12,31 @@ var import_execa = require("execa");
12
12
  // src/lib/operations/utils/config.ts
13
13
  var import_node_fs = require("fs");
14
14
  var CONFIG_FILE = "./aakaar.json";
15
- var config = (0, import_node_fs.existsSync)(CONFIG_FILE) ? JSON.parse((0, import_node_fs.readFileSync)(CONFIG_FILE, "utf-8")) : {
15
+ var DEFAULT_CONFIG = {
16
+ host: "http://aakaar.navnote.com",
17
+ core: {
18
+ path: "src/design",
19
+ import: "../../core"
20
+ },
16
21
  tokens: {
17
- color: "006875",
18
- output: "./css"
22
+ color: "a42700",
23
+ strategy: "harmony",
24
+ output: "src/design/css"
19
25
  },
20
26
  react: {
21
- output: "./react/components"
27
+ output: "src/design/components"
28
+ }
29
+ };
30
+ var config = (0, import_node_fs.existsSync)(CONFIG_FILE) ? JSON.parse((0, import_node_fs.readFileSync)(CONFIG_FILE, "utf-8")) : DEFAULT_CONFIG;
31
+ var writeConfig = (config2) => {
32
+ (0, import_node_fs.writeFileSync)(CONFIG_FILE, JSON.stringify(config2, null, 2));
33
+ };
34
+ var readConfig = () => {
35
+ if ((0, import_node_fs.existsSync)(CONFIG_FILE)) {
36
+ return JSON.parse((0, import_node_fs.readFileSync)(CONFIG_FILE, "utf-8"));
22
37
  }
38
+ writeConfig(DEFAULT_CONFIG);
39
+ return DEFAULT_CONFIG;
23
40
  };
24
41
 
25
42
  // src/lib/operations/utils/pm.ts
@@ -52,16 +69,20 @@ var add = new import_commander.Command().name("add").description("add component
52
69
  const response = await fetch(componentUrl);
53
70
  const componentConfig = await response.json();
54
71
  if (componentConfig.dependencies) {
55
- await (0, import_execa.execa)(
56
- packageManager,
57
- [
58
- packageManager === "npm" ? "install" : "add",
59
- ...componentConfig.dependencies
60
- ],
61
- {
62
- cwd
63
- }
64
- );
72
+ if (!config.disableInstall) {
73
+ await (0, import_execa.execa)(
74
+ packageManager,
75
+ [
76
+ packageManager === "npm" ? "install" : "add",
77
+ ...componentConfig.dependencies
78
+ ],
79
+ {
80
+ cwd
81
+ }
82
+ );
83
+ } else {
84
+ console.log(`Skipping installation of dependencies for ${component}`);
85
+ }
65
86
  }
66
87
  if (componentConfig.files.length > 0) {
67
88
  for (const file of componentConfig.files) {
@@ -122,26 +143,7 @@ var verify = async () => {
122
143
  // src/lib/operations/commands/setup.ts
123
144
  var setup = new import_commander2.Command().name("setup").description("setup the aakaar ui").action(async () => {
124
145
  await verify();
125
- const aakaarJson = {
126
- host: "http://aakaar.navnote.com",
127
- core: {
128
- path: "src/design",
129
- import: "../../core"
130
- },
131
- tokens: {
132
- color: "a42700",
133
- output: "src/design/css"
134
- },
135
- react: {
136
- output: "src/design/components"
137
- }
138
- };
139
- const finalAakaarJson = (0, import_node_fs4.existsSync)("aakaar.json") ? JSON.parse((0, import_node_fs4.readFileSync)("aakaar.json", "utf-8")) : aakaarJson;
140
- if (!(0, import_node_fs4.existsSync)("aakaar.json")) {
141
- (0, import_node_fs4.writeFileSync)("aakaar.json", JSON.stringify(aakaarJson, null, 2));
142
- } else {
143
- console.log("aakaar.json already exists");
144
- }
146
+ const finalAakaarJson = readConfig();
145
147
  const proceed = await new Promise((resolve) => {
146
148
  const readline = (0, import_node_readline.createInterface)({
147
149
  input: process.stdin,
@@ -203,12 +205,19 @@ var import_commander3 = require("commander");
203
205
  var token = new import_commander3.Command().name("token").description("build design tokens for your project").option(
204
206
  "-c, --color <color>",
205
207
  "Hex code of the source color, example, 006875. If it is not provided, the default color is used i.e. 006875"
206
- ).option("-o, --output <output>", "Output path for generated tokens.").action(async ({ color, output }) => {
208
+ ).option("-o, --output <output>", "Output path for generated tokens.").option(
209
+ "-s, --strategy <strategy>",
210
+ "Color generation strategy: 'material' or 'harmony'. Default is 'harmony'",
211
+ "harmony"
212
+ ).action(async ({ color, output, strategy }) => {
207
213
  verify();
208
214
  const finalColor = color || config.tokens.color;
215
+ const finalStrategy = strategy || config.tokens.strategy;
209
216
  const finalOutput = output || config.tokens.output;
210
- console.log(`Generating tokens for color: ${finalColor}`);
211
- const cssOutput = (0, import_dictionary.runCss)(`#${finalColor}`);
217
+ console.log(
218
+ `Generating tokens for color: ${finalColor} using ${finalStrategy} strategy`
219
+ );
220
+ const cssOutput = (0, import_dictionary.runCss)(`#${finalColor}`, finalStrategy);
212
221
  if (!(0, import_node_fs5.existsSync)(finalOutput)) {
213
222
  (0, import_node_fs5.mkdirSync)(finalOutput, {
214
223
  recursive: true
package/dist/index.js CHANGED
@@ -4,21 +4,38 @@
4
4
  import { Command as Command4 } from "commander";
5
5
 
6
6
  // src/lib/operations/commands/add.ts
7
- import { existsSync as existsSync2, mkdirSync, writeFileSync } from "fs";
7
+ import { existsSync as existsSync2, mkdirSync, writeFileSync as writeFileSync2 } from "fs";
8
8
  import { Command } from "commander";
9
9
  import { execa } from "execa";
10
10
 
11
11
  // src/lib/operations/utils/config.ts
12
- import { existsSync, readFileSync } from "fs";
12
+ import { existsSync, readFileSync, writeFileSync } from "fs";
13
13
  var CONFIG_FILE = "./aakaar.json";
14
- var config = existsSync(CONFIG_FILE) ? JSON.parse(readFileSync(CONFIG_FILE, "utf-8")) : {
14
+ var DEFAULT_CONFIG = {
15
+ host: "http://aakaar.navnote.com",
16
+ core: {
17
+ path: "src/design",
18
+ import: "../../core"
19
+ },
15
20
  tokens: {
16
- color: "006875",
17
- output: "./css"
21
+ color: "a42700",
22
+ strategy: "harmony",
23
+ output: "src/design/css"
18
24
  },
19
25
  react: {
20
- output: "./react/components"
26
+ output: "src/design/components"
27
+ }
28
+ };
29
+ var config = existsSync(CONFIG_FILE) ? JSON.parse(readFileSync(CONFIG_FILE, "utf-8")) : DEFAULT_CONFIG;
30
+ var writeConfig = (config2) => {
31
+ writeFileSync(CONFIG_FILE, JSON.stringify(config2, null, 2));
32
+ };
33
+ var readConfig = () => {
34
+ if (existsSync(CONFIG_FILE)) {
35
+ return JSON.parse(readFileSync(CONFIG_FILE, "utf-8"));
21
36
  }
37
+ writeConfig(DEFAULT_CONFIG);
38
+ return DEFAULT_CONFIG;
22
39
  };
23
40
 
24
41
  // src/lib/operations/utils/pm.ts
@@ -51,16 +68,20 @@ var add = new Command().name("add").description("add component to your project")
51
68
  const response = await fetch(componentUrl);
52
69
  const componentConfig = await response.json();
53
70
  if (componentConfig.dependencies) {
54
- await execa(
55
- packageManager,
56
- [
57
- packageManager === "npm" ? "install" : "add",
58
- ...componentConfig.dependencies
59
- ],
60
- {
61
- cwd
62
- }
63
- );
71
+ if (!config.disableInstall) {
72
+ await execa(
73
+ packageManager,
74
+ [
75
+ packageManager === "npm" ? "install" : "add",
76
+ ...componentConfig.dependencies
77
+ ],
78
+ {
79
+ cwd
80
+ }
81
+ );
82
+ } else {
83
+ console.log(`Skipping installation of dependencies for ${component}`);
84
+ }
64
85
  }
65
86
  if (componentConfig.files.length > 0) {
66
87
  for (const file of componentConfig.files) {
@@ -70,7 +91,7 @@ var add = new Command().name("add").description("add component to your project")
70
91
  "../../core/core",
71
92
  `${config.core.import}`
72
93
  );
73
- writeFileSync(filePath, file.content, {
94
+ writeFileSync2(filePath, file.content, {
74
95
  encoding: "utf8",
75
96
  flag: "w"
76
97
  });
@@ -79,7 +100,7 @@ var add = new Command().name("add").description("add component to your project")
79
100
  });
80
101
 
81
102
  // src/lib/operations/commands/setup.ts
82
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
103
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, writeFileSync as writeFileSync3 } from "fs";
83
104
  import { createInterface } from "readline";
84
105
  import { Command as Command2 } from "commander";
85
106
 
@@ -121,26 +142,7 @@ var verify = async () => {
121
142
  // src/lib/operations/commands/setup.ts
122
143
  var setup = new Command2().name("setup").description("setup the aakaar ui").action(async () => {
123
144
  await verify();
124
- const aakaarJson = {
125
- host: "http://aakaar.navnote.com",
126
- core: {
127
- path: "src/design",
128
- import: "../../core"
129
- },
130
- tokens: {
131
- color: "a42700",
132
- output: "src/design/css"
133
- },
134
- react: {
135
- output: "src/design/components"
136
- }
137
- };
138
- const finalAakaarJson = existsSync3("aakaar.json") ? JSON.parse(readFileSync3("aakaar.json", "utf-8")) : aakaarJson;
139
- if (!existsSync3("aakaar.json")) {
140
- writeFileSync2("aakaar.json", JSON.stringify(aakaarJson, null, 2));
141
- } else {
142
- console.log("aakaar.json already exists");
143
- }
145
+ const finalAakaarJson = readConfig();
144
146
  const proceed = await new Promise((resolve) => {
145
147
  const readline = createInterface({
146
148
  input: process.stdin,
@@ -187,7 +189,7 @@ var setup = new Command2().name("setup").description("setup the aakaar ui").acti
187
189
  if (!existsSync3(corePath)) {
188
190
  mkdirSync2(corePath, { recursive: true });
189
191
  }
190
- writeFileSync2(`${corePath}/${firstCoreFile.name}`, firstCoreFile.content, {
192
+ writeFileSync3(`${corePath}/${firstCoreFile.name}`, firstCoreFile.content, {
191
193
  encoding: "utf-8",
192
194
  flag: "w"
193
195
  });
@@ -196,24 +198,31 @@ var setup = new Command2().name("setup").description("setup the aakaar ui").acti
196
198
  });
197
199
 
198
200
  // src/lib/operations/commands/token.ts
199
- import { existsSync as existsSync4, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
201
+ import { existsSync as existsSync4, mkdirSync as mkdirSync3, writeFileSync as writeFileSync4 } from "fs";
200
202
  import { runCss } from "@aakaar/dictionary";
201
203
  import { Command as Command3 } from "commander";
202
204
  var token = new Command3().name("token").description("build design tokens for your project").option(
203
205
  "-c, --color <color>",
204
206
  "Hex code of the source color, example, 006875. If it is not provided, the default color is used i.e. 006875"
205
- ).option("-o, --output <output>", "Output path for generated tokens.").action(async ({ color, output }) => {
207
+ ).option("-o, --output <output>", "Output path for generated tokens.").option(
208
+ "-s, --strategy <strategy>",
209
+ "Color generation strategy: 'material' or 'harmony'. Default is 'harmony'",
210
+ "harmony"
211
+ ).action(async ({ color, output, strategy }) => {
206
212
  verify();
207
213
  const finalColor = color || config.tokens.color;
214
+ const finalStrategy = strategy || config.tokens.strategy;
208
215
  const finalOutput = output || config.tokens.output;
209
- console.log(`Generating tokens for color: ${finalColor}`);
210
- const cssOutput = runCss(`#${finalColor}`);
216
+ console.log(
217
+ `Generating tokens for color: ${finalColor} using ${finalStrategy} strategy`
218
+ );
219
+ const cssOutput = runCss(`#${finalColor}`, finalStrategy);
211
220
  if (!existsSync4(finalOutput)) {
212
221
  mkdirSync3(finalOutput, {
213
222
  recursive: true
214
223
  });
215
224
  }
216
- writeFileSync3(`${finalOutput}/tokens.css`, cssOutput, {
225
+ writeFileSync4(`${finalOutput}/tokens.css`, cssOutput, {
217
226
  encoding: "utf8",
218
227
  flag: "w"
219
228
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aakaar/cli",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -23,8 +23,8 @@
23
23
  "commander": "^12.1.0",
24
24
  "execa": "^9.6.0",
25
25
  "signal-exit": "^4.1.0",
26
- "@aakaar/dictionary": "0.0.2",
27
- "@aakaar/global": "0.0.2"
26
+ "@aakaar/dictionary": "0.0.4",
27
+ "@aakaar/global": "0.0.4"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "tsup src/index.ts --format esm,cjs --dts",