@ethlete/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/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @ethlete/cli
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#609](https://github.com/ethlete-io/ethdk/pull/609) [`39eda21`](https://github.com/ethlete-io/ethdk/commit/39eda21929f50b75071ad464c3331d85f3645fa1) Thanks [@nziermann](https://github.com/nziermann)! - Add a dsp function to generate css based on input file
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # cli
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build cli` to build the library.
8
+
9
+ ## Running unit tests
10
+
11
+ Run `nx test cli` to execute the unit tests via [Jest](https://jestjs.io).
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "@ethlete/cli",
3
+ "version": "0.1.0",
4
+ "type": "commonjs",
5
+ "bin": {
6
+ "et": "./src/index.js"
7
+ },
8
+ "dependencies": {
9
+ "jiti": "1.18.2",
10
+ "sucrase": "3.32.0"
11
+ },
12
+ "peerDependencies": {
13
+ "@ethlete/dsp": "0.1.0",
14
+ "tslib": "2.5.0"
15
+ },
16
+ "main": "./src/index.js",
17
+ "types": "./src/index.d.ts"
18
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/src/index.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const lib_1 = require("./lib");
5
+ const cli = (args) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
6
+ const cliFunctionArg = args[0];
7
+ switch (cliFunctionArg) {
8
+ case 'dsp':
9
+ yield (0, lib_1.dsp)(args);
10
+ break;
11
+ default:
12
+ console.log(`No command found named ${cliFunctionArg}. Available commands are: dsp`);
13
+ break;
14
+ }
15
+ });
16
+ // Get the command line arguments and normalize them
17
+ const args = process.argv.slice(2).join('=').split('=');
18
+ cli(args);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/cli/src/index.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAE5B,MAAM,GAAG,GAAG,CAAO,IAAc,EAAE,EAAE;IACnC,MAAM,cAAc,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAE/B,QAAQ,cAAc,EAAE;QACtB,KAAK,KAAK;YACR,MAAM,IAAA,SAAG,EAAC,IAAI,CAAC,CAAC;YAChB,MAAM;QAER;YACE,OAAO,CAAC,GAAG,CAAC,0BAA0B,cAAc,+BAA+B,CAAC,CAAC;YACrF,MAAM;KACT;AACH,CAAC,CAAA,CAAC;AAEF,oDAAoD;AACpD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAExD,GAAG,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const dsp: (args: string[]) => Promise<void>;
package/src/lib/dsp.js ADDED
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dsp = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const dsp_1 = require("@ethlete/dsp");
6
+ const jiti_1 = tslib_1.__importDefault(require("jiti"));
7
+ const path_1 = tslib_1.__importDefault(require("path"));
8
+ const sucrase_1 = require("sucrase");
9
+ function assertIsDesignSystem(designSystem) {
10
+ if (!designSystem ||
11
+ typeof designSystem !== 'object' ||
12
+ (typeof designSystem === 'object' &&
13
+ (!('name' in designSystem) || !('ref' in designSystem) || !('sys' in designSystem)))) {
14
+ console.error('No design system found or invalid design system');
15
+ process.exit(1);
16
+ }
17
+ }
18
+ const dsp = (args) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
19
+ const inputIndex = args.findIndex((arg) => arg.includes('--input') || arg.includes('-i'));
20
+ const input = args[inputIndex + 1];
21
+ if (!input) {
22
+ console.error('No input file specified. Use -i or --input');
23
+ process.exit(1);
24
+ }
25
+ const outputIndex = args.findIndex((arg) => arg.includes('--output') || arg.includes('-o'));
26
+ const output = args[outputIndex + 1];
27
+ if (!output) {
28
+ console.error('No output file specified. Use -o or --output');
29
+ process.exit(1);
30
+ }
31
+ const filePath = path_1.default.join(process.cwd(), input);
32
+ const jiti = (0, jiti_1.default)(__filename, {
33
+ interopDefault: true,
34
+ transform: (opts) => {
35
+ return (0, sucrase_1.transform)(opts.source, {
36
+ transforms: ['typescript', 'imports'],
37
+ });
38
+ },
39
+ });
40
+ const designSystem = jiti(filePath);
41
+ assertIsDesignSystem(designSystem);
42
+ const cssVariables = (0, dsp_1.generateCssVariables)({
43
+ designSystem,
44
+ });
45
+ try {
46
+ yield (0, dsp_1.writeCssVariables)({
47
+ designSystem,
48
+ cssVariables,
49
+ output,
50
+ });
51
+ console.log(`Design system written to file at ${output}. Have a nice day! 😘`);
52
+ }
53
+ catch (error) {
54
+ console.error(error);
55
+ }
56
+ });
57
+ exports.dsp = dsp;
58
+ //# sourceMappingURL=dsp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dsp.js","sourceRoot":"","sources":["../../../../../libs/cli/src/lib/dsp.ts"],"names":[],"mappings":";;;;AAAA,sCAAqF;AACrF,wDAA+B;AAC/B,wDAAwB;AACxB,qCAAoC;AAEpC,SAAS,oBAAoB,CAAC,YAAqB;IACjD,IACE,CAAC,YAAY;QACb,OAAO,YAAY,KAAK,QAAQ;QAChC,CAAC,OAAO,YAAY,KAAK,QAAQ;YAC/B,CAAC,CAAC,CAAC,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,YAAY,CAAC,CA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AAE,SAAS,CAAC;aACtC,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IAEpC,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAEnC,MAAM,YAAY,GAAG,IAAA,0BAAoB,EAAC;QACxC,YAAY;KACb,CAAC,CAAC;IAEH,IAAI;QACF,MAAM,IAAA,uBAAiB,EAAC;YACtB,YAAY;YACZ,YAAY;YACZ,MAAM;SACP,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,oCAAoC,MAAM,uBAAuB,CAAC,CAAC;KAChF;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACtB;AACH,CAAC,CAAA,CAAC;AAhDW,QAAA,GAAG,OAgDd"}
@@ -0,0 +1 @@
1
+ export * from './dsp';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./dsp"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/cli/src/lib/index.ts"],"names":[],"mappings":";;;AAAA,gDAAsB"}