@blueprintui/cli 0.0.4 → 0.0.5

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/import-assert.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import path from 'path';
1
+ import { path } from 'zx';
2
2
 
3
3
  // temp workaround due to package "string-to-template-literal" not shipping valid esm module
4
4
 
package/index.mjs CHANGED
@@ -1,16 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import path from 'path';
4
3
  import * as url from 'url';
5
- import loadConfigFile from 'rollup/loadConfigFile';
4
+ import { path } from 'zx';
5
+ import { spinner } from 'zx/experimental';
6
6
  import { rollup, watch } from 'rollup';
7
7
  import { program } from 'commander';
8
+ import loadConfigFile from 'rollup/loadConfigFile';
8
9
 
9
10
  const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
10
- const ERROR = '\x1b[31m%s\x1b[0m'; //red
11
- const WARN = '\x1b[33m%s\x1b[0m'; //yellow
12
- const INFO = '\x1b[36m%s\x1b[0m'; //cyan
13
- const SUCCESS = '\x1b[32m%s\x1b[0m'; //green
11
+
12
+ const status = {
13
+ error: '\x1b[31m%s\x1b[0m',
14
+ warn: '\x1b[33m%s\x1b[0m',
15
+ info: '\x1b[36m%s\x1b[0m',
16
+ success: '\x1b[32m%s\x1b[0m'
17
+ };
14
18
 
15
19
  program
16
20
  .command('build')
@@ -20,7 +24,7 @@ program
20
24
  .description('build library')
21
25
  .action(async (options, command) => {
22
26
  process.env.BLUEPRINTUI_BUILD = options.prod || !options.watch ? 'production' : 'development';
23
- process.env.BLUEPRINTUI_CONFIG = command.args[0] ? path.resolve(command.args[0]) : path.resolve(process.cwd(), './rollup.config.js');
27
+ process.env.BLUEPRINTUI_CONFIG = command.args[0] ? path.resolve(command.args[0]) : path.resolve('./blueprint.config.js');
24
28
  buildRollup(options);
25
29
  });
26
30
 
@@ -40,16 +44,15 @@ function buildRollup(args) {
40
44
  let bundle;
41
45
  let buildFailed = false;
42
46
  try {
43
- console.log(INFO, 'Building...');
44
- bundle = await rollup(options[0]);
47
+ bundle = await spinner('Building...', async () => await rollup(options[0]));
45
48
  await bundle.write(options[0].output[0]);
46
49
  } catch (error) {
47
50
  buildFailed = true;
48
- console.error(ERROR, error);
51
+ console.error(status.error, error);
49
52
  }
50
53
  if (bundle) {
51
54
  const end = Date.now();
52
- console.log(SUCCESS, `Completed in ${(end - start) / 1000} seconds 🎉`);
55
+ console.log(status.success, `Completed in ${(end - start) / 1000} seconds 🎉`);
53
56
  await bundle.close();
54
57
  }
55
58
  process.exit(buildFailed ? 1 : 0);
@@ -66,17 +69,17 @@ function buildRollup(args) {
66
69
 
67
70
  switch (event.code) {
68
71
  case 'START':
69
- console.log(INFO, 'Building...');
72
+ console.log(status.info, 'Building...');
70
73
  break;
71
74
  case 'ERROR':
72
- console.error(ERROR, event.error);
75
+ console.error(status.error, event.error);
73
76
  event.result.close();
74
77
  break;
75
78
  case 'WARN':
76
- console.error(ERROR, event.error);
79
+ console.error(status.warn, event.error);
77
80
  break;
78
81
  case 'BUNDLE_END':
79
- console.log(SUCCESS, `Complete in ${event.duration / 1000} seconds`);
82
+ console.log(status.success, `Complete in ${event.duration / 1000} seconds`);
80
83
  event.result.close();
81
84
  break;
82
85
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueprintui/cli",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "",
5
5
  "main": "./index.mjs",
6
6
  "bin": {
@@ -33,6 +33,7 @@
33
33
  "rollup-plugin-shell": "^1.0.3",
34
34
  "rollup-plugin-terser": "^7.0.2",
35
35
  "tslib": "2.3.1",
36
- "typescript": "4.6.4"
36
+ "typescript": "4.6.4",
37
+ "zx": "^7.0.0"
37
38
  }
38
39
  }
package/rollup.config.mjs CHANGED
@@ -1,5 +1,4 @@
1
- import fs from 'fs-extra';
2
- import glob from 'glob';
1
+ import * as csso from 'csso';
3
2
  import typescript from '@rollup/plugin-typescript';
4
3
  import nodeResolve from '@rollup/plugin-node-resolve';
5
4
  import replace from '@rollup/plugin-replace';
@@ -8,21 +7,17 @@ import copy from 'rollup-plugin-copy';
8
7
  import del from 'rollup-plugin-delete';
9
8
  import minifyHTML from 'rollup-plugin-minify-html-literals';
10
9
  import execute from 'rollup-plugin-shell';
10
+ import { fs, glob, path } from 'zx';
11
+ import { extname } from 'path';
11
12
  import { terser } from 'rollup-plugin-terser';
12
- import { resolve, extname } from 'path';
13
- import { importAssertionsPlugin } from './import-assert.mjs';
14
- // import { importAssertionsPlugin } from 'rollup-plugin-import-assert';
15
13
  import { importAssertions } from 'acorn-import-assertions';
16
14
  import { idiomaticDecoratorsTransformer, constructorCleanupTransformer } from '@lit/ts-transformers';
17
- import * as csso from 'csso';
18
- import { exec as _exec } from 'child_process';
19
- import { promisify } from 'util';
20
- import { dirname } from 'path';
21
15
  import { fileURLToPath } from 'url';
16
+ import { importAssertionsPlugin } from './import-assert.mjs';
17
+ // import { importAssertionsPlugin } from 'rollup-plugin-import-assert';
22
18
 
23
- const exec = promisify(_exec);
24
19
  const __filename = fileURLToPath(import.meta.url);
25
- const __dirname = dirname(__filename);
20
+ const __dirname = path.dirname(__filename);
26
21
 
27
22
  let userConfig = { };
28
23
  if (process.env.BLUEPRINTUI_CONFIG) {
@@ -38,19 +33,19 @@ const config = {
38
33
  tsconfig: './tsconfig.lib.json',
39
34
  customElementsManifestConfig: './custom-elements-manifest.config.mjs',
40
35
  sourcemap: false,
41
- ...userConfig.default.library
36
+ ...userConfig.default?.library
42
37
  };
43
38
 
44
39
  const cwd = process.cwd();
45
40
  const project = {
46
41
  externals: config.externals,
47
- packageFile: resolve(cwd, './package.json'),
48
- assets: config.assets.map(a => resolve(cwd, a)),
49
- baseDir: resolve(cwd, config.baseDir),
50
- outDir: resolve(cwd, config.outDir),
51
- entryPoints: config.entryPoints.map(e => resolve(cwd, e)),
52
- tsconfig: resolve(cwd, config.tsconfig),
53
- customElementsManifestConfig: resolve(__dirname, config.customElementsManifestConfig),
42
+ packageFile: path.resolve(cwd, './package.json'),
43
+ assets: config.assets.map(a => path.resolve(cwd, a)),
44
+ baseDir: path.resolve(cwd, config.baseDir),
45
+ outDir: path.resolve(cwd, config.outDir),
46
+ entryPoints: config.entryPoints.map(e => path.resolve(cwd, e)),
47
+ tsconfig: path.resolve(cwd, config.tsconfig),
48
+ customElementsManifestConfig: path.resolve(__dirname, config.customElementsManifestConfig),
54
49
  prod: process.env.BLUEPRINTUI_BUILD === 'production',
55
50
  sourcemap: config.sourcemap
56
51
  }
@@ -94,7 +89,7 @@ function copyAssets() {
94
89
  }
95
90
 
96
91
  function createEntrypoints() {
97
- return virtual({ 'library-entry-points': [...project.entryPoints.flatMap(i => glob.sync(i))].map(entry => `export * from '${entry}';`).join('\n') });
92
+ return virtual({ 'library-entry-points': [...project.entryPoints.flatMap(i => glob.globbySync(i))].map(entry => `export * from '${entry}';`).join('\n') });
98
93
  }
99
94
 
100
95
  function compileTypescript() {
@@ -137,7 +132,7 @@ function customElementsAnalyzer() {
137
132
  if (copied) {
138
133
  return;
139
134
  } else {
140
- await exec(`cem analyze --config ${project.customElementsManifestConfig}`);
135
+ await $`cem analyze --config ${project.customElementsManifestConfig}`;
141
136
  const json = await fs.readJson(project.packageFile);
142
137
  const packageFile = { ...json, customElements: './custom-elements.json', scripts: undefined, devDependencies: undefined };
143
138
  await fs.writeFile(`${project.outDir}/package.json`, JSON.stringify(packageFile, null, 2));
@@ -148,7 +143,7 @@ function customElementsAnalyzer() {
148
143
 
149
144
  function cssOptimize() {
150
145
  return {
151
- load(id) { return id.slice(-4) === '.css' ? this.addWatchFile(resolve(id)) : null },
146
+ load(id) { return id.slice(-4) === '.css' ? this.addWatchFile(path.resolve(id)) : null },
152
147
  transform: async (css, id) => id.slice(-4) === '.css' ? ({ code: csso.minify(css, { comments: false }).css, map: { mappings: '' } }) : null
153
148
  };
154
149
  };