@blockquote/create-wc 2.7.5 → 2.8.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockquote/create-wc",
3
- "version": "2.7.5",
3
+ "version": "2.8.1",
4
4
  "description": "Web component with Lit scaffolding - Extending Open Web Component",
5
5
  "keywords": [
6
6
  "Lit",
package/src/Generator.js CHANGED
@@ -1,4 +1,42 @@
1
+ import prompts from 'prompts';
2
+ import {spawn} from 'child_process';
1
3
  import _Generator from '@open-wc/create/dist/Generator.js';
4
+ import {writeFilesToDisk} from '@open-wc/create/dist/core.js';
5
+
6
+ const isWindows = process.platform === 'win32';
7
+
8
+ /**
9
+ * @param {string} command
10
+ * @param {object} options
11
+ */
12
+ function _install(command = 'npm', options = {}) {
13
+ return new Promise((resolve, reject) => {
14
+ const cmdCommand = isWindows ? `${command}.cmd` : command;
15
+
16
+ const install = spawn(cmdCommand, ['install'], {
17
+ ...options,
18
+ stdio: 'inherit',
19
+ });
20
+
21
+ install.on('close', (code) => {
22
+ if (code === 0) resolve();
23
+ else reject(new Error(`${command} install failed with code ${code}`));
24
+ });
25
+ });
26
+ }
27
+
28
+ /**
29
+ *
30
+ * @param {string} where
31
+ * @param {string} command
32
+ */
33
+ export async function installNpm(where, command) {
34
+ console.log('');
35
+ console.log('Installing dependencies...');
36
+ console.log(`Using ${command} to install...`);
37
+ await _install(command, {cwd: where});
38
+ console.log('');
39
+ }
2
40
 
3
41
  /**
4
42
  * Options for the generator
@@ -9,13 +47,61 @@ import _Generator from '@open-wc/create/dist/Generator.js';
9
47
  * @property {'true'|'false'} [writeToDisk] whether to write to disk
10
48
  * @property {'yarn'|'npm'|'false'} [installDependencies] whether and with which tool to install dependencies
11
49
  */
12
-
13
50
  class Generator extends _Generator.default {
14
51
  constructor() {
15
52
  super();
16
53
  this.wantsRecreateInfo = false;
17
54
  this.generatorName = '@blockquote/wc';
18
55
  }
56
+ async end() {
57
+ if (this.wantsWriteToDisk) {
58
+ this.options.writeToDisk = await writeFilesToDisk();
59
+ }
60
+
61
+ if (this.wantsNpmInstall) {
62
+ const answers = await prompts(
63
+ [
64
+ {
65
+ type: 'select',
66
+ name: 'installDependencies',
67
+ message: 'Do you want to install dependencies?',
68
+ choices: [
69
+ {title: 'No', value: 'false'},
70
+ {title: 'Yes, with npm', value: 'npm'},
71
+ {title: 'Yes, with pnpm', value: 'pnpm'},
72
+ ],
73
+ },
74
+ ],
75
+ {
76
+ onCancel: () => {
77
+ process.exit();
78
+ },
79
+ }
80
+ );
81
+
82
+ this.options.installDependencies = answers.installDependencies;
83
+ const {installDependencies} = this.options;
84
+ if (installDependencies === 'pnpm' || installDependencies === 'npm') {
85
+ await installNpm(this.options.destinationPath, installDependencies);
86
+
87
+ await new Promise((resolve, reject) => {
88
+ const cmdInstallDependencies = isWindows
89
+ ? `${installDependencies}.cmd`
90
+ : installDependencies;
91
+
92
+ const install = spawn(cmdInstallDependencies, ['run', 'analyze'], {
93
+ cwd: this.options.destinationPath,
94
+ stdio: 'inherit',
95
+ });
96
+
97
+ install.on('close', (code) => {
98
+ if (code === 0) resolve();
99
+ else reject(new Error(`${installDependencies} run analyze failed`));
100
+ });
101
+ });
102
+ }
103
+ }
104
+ }
19
105
  }
20
106
 
21
107
  export default Generator;
@@ -25,6 +25,7 @@ const baseConfig = [
25
25
  sourceType: 'module',
26
26
  globals: {
27
27
  ...globals.browser,
28
+ ...globals.es2023,
28
29
  ...globals.mocha,
29
30
  },
30
31
  },
@@ -9,11 +9,11 @@
9
9
  "experimentalDecorators": true,
10
10
  "forceConsistentCasingInFileNames": true,
11
11
  "lib": [
12
- "es2022",
12
+ "es2023",
13
13
  "DOM",
14
14
  "DOM.Iterable"
15
15
  ],
16
- "module": "es2022",
16
+ "module": "esnext",
17
17
  "moduleResolution": "Bundler",
18
18
  "noFallthroughCasesInSwitch": true,
19
19
  "noImplicitAny": true,
@@ -29,7 +29,7 @@
29
29
  "sourceMap": true,
30
30
  "strict": true,
31
31
  "stripInternal": true,
32
- "target": "es2022",
32
+ "target": "es2023",
33
33
  "types": [
34
34
  "mocha"
35
35
  ],