neutrinos-cli 1.0.0 → 1.0.2

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.
@@ -19,6 +19,7 @@ import { getDefaultIconPath } from '../utils/path-utils.js';
19
19
  import { getLoggedInUserSession } from '../utils/user-seesion-utils.js';
20
20
  import { selectPackages } from './select-packages.mjs';
21
21
 
22
+ // @ts-ignore
22
23
  export async function publish(name, wsPath, options) {
23
24
  const session = await getLoggedInUserSession();
24
25
  const packages = (await selectPackages(wsPath, options.all ?? false, name)) || [];
@@ -32,6 +33,7 @@ export async function publish(name, wsPath, options) {
32
33
  );
33
34
  }
34
35
 
36
+ // @ts-ignore
35
37
  function validateAlphaPackage(pkgJsonPath, pkgJson, isModule) {
36
38
  if (!pkgJson.alpha) throw new Error('It is not an alpha package');
37
39
  if (isModule && pkgJson.alpha.metadata?.exposedName) {
@@ -48,6 +50,7 @@ function validateAlphaPackage(pkgJsonPath, pkgJson, isModule) {
48
50
  }
49
51
  }
50
52
 
53
+ // @ts-ignore
51
54
  function getPackageInfo(pkgJson, componentDirPath) {
52
55
  if (!pkgJson.alpha.component) return { name: pkgJson.name, icon: null };
53
56
 
@@ -58,12 +61,14 @@ function getPackageInfo(pkgJson, componentDirPath) {
58
61
  };
59
62
  }
60
63
 
64
+ // @ts-ignore
61
65
  function updatePackageJson(packageJsonPath, packageJson, packageId, versionId) {
62
66
  packageJson.alpha.packageId = packageId;
63
67
  packageJson.alpha.versionId = versionId;
64
68
  writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
65
69
  }
66
70
 
71
+ // @ts-ignore
67
72
  async function processPackagePublish(componentDirPath, packageName, wsPath, options, session) {
68
73
  const pkgJsonPath = join(componentDirPath, 'package.json');
69
74
  const pkgJson = getPackageJson(pkgJsonPath);
@@ -92,10 +97,12 @@ async function processPackagePublish(componentDirPath, packageName, wsPath, opti
92
97
  session,
93
98
  );
94
99
  }
100
+ // @ts-ignore
95
101
  const isProdPublish = (mode) => {
96
102
  return mode ? mode.trim().toLowerCase() === 'prod' : false;
97
103
  };
98
104
 
105
+ // @ts-ignore
99
106
  async function publishVersionedPackage(pkgJson, pkgJsonPath, componentDirPath, options, zipStream, session) {
100
107
  await incrementPackageVersion(componentDirPath, options);
101
108
  pkgJson = getPackageJson(pkgJsonPath);
@@ -111,6 +118,7 @@ async function publishVersionedPackage(pkgJson, pkgJsonPath, componentDirPath, o
111
118
  return response;
112
119
  }
113
120
 
121
+ // @ts-ignore
114
122
  async function publishNewPackage(pkgJson, pkgJsonPath, componentDirPath, options, zipStream, packageName, session) {
115
123
  const pkgInfo = getPackageInfo(pkgJson, componentDirPath);
116
124
  options.icon = options.icon ?? pkgInfo.icon;
@@ -128,8 +136,10 @@ async function publishNewPackage(pkgJson, pkgJsonPath, componentDirPath, options
128
136
  ? []
129
137
  : await getImagesPath(componentDirPath);
130
138
 
139
+ // @ts-ignore
131
140
  const imagesStream = imagesForPkg.map((imagePath) => getIconStream(imagePath, componentDirPath)).filter(Boolean);
132
141
 
142
+ // @ts-ignore
133
143
  const displayName = options.displayName || (await inquiry(DISPLAY_NAME_QUERY)).name;
134
144
 
135
145
  const formData = prepareFormData(displayName, pkgJson, zipStream, iconStream, imagesStream, packageName);
@@ -146,9 +156,11 @@ async function publishNewPackage(pkgJson, pkgJsonPath, componentDirPath, options
146
156
  return response;
147
157
  }
148
158
 
159
+ // @ts-ignore
149
160
  async function incrementPackageVersion(componentDirPath, options) {
150
161
  const versionType =
151
162
  options.versionType ||
163
+ // @ts-ignore
152
164
  (
153
165
  await inquiry({
154
166
  type: 'list',
@@ -164,6 +176,7 @@ async function incrementPackageVersion(componentDirPath, options) {
164
176
  });
165
177
  }
166
178
 
179
+ // @ts-ignore
167
180
  function prepareVersionFormData(packageJson, zipStream, iconStream, imagesStream) {
168
181
  const formData = new FormData();
169
182
  const packageMetadata = JSON.stringify({
@@ -179,11 +192,13 @@ function prepareVersionFormData(packageJson, zipStream, iconStream, imagesStream
179
192
  if (iconStream) {
180
193
  formData.append('icon', iconStream);
181
194
  }
195
+ // @ts-ignore
182
196
  (imagesStream || []).forEach((is) => formData.append('images', is));
183
197
 
184
198
  return formData;
185
199
  }
186
200
 
201
+ // @ts-ignore
187
202
  function prepareFormData(name, packageJson, zipStream, iconStream, imagesStream, packageName) {
188
203
  const formData = new FormData();
189
204
  const packageMetadata = JSON.stringify({
@@ -204,16 +219,21 @@ function prepareFormData(name, packageJson, zipStream, iconStream, imagesStream,
204
219
  if (iconStream) {
205
220
  formData.append('icon', iconStream);
206
221
  }
222
+ // @ts-ignore
207
223
  imagesStream.forEach((is) => formData.append('images', is));
208
224
 
209
225
  return formData;
210
226
  }
211
227
 
228
+ // @ts-ignore
212
229
  async function getIconPath(componentDirPath) {
230
+ // @ts-ignore
213
231
  return getPackageIcon(componentDirPath) || (await inquiry(ICON_FILE_PATH_QUERY)).value;
214
232
  }
215
233
 
234
+ // @ts-ignore
216
235
  async function getImagesPath(componentDirPath) {
217
236
  const images = getPackageImages(componentDirPath) || [];
237
+ // @ts-ignore
218
238
  return images.length ? images : (await multipleInquiry(IMAGES_FILE_PATH_QUERY)).map((img) => img.value);
219
239
  }
@@ -99,9 +99,9 @@ const initializePackages = async (dir) => {
99
99
  inprogress(`Adding default npm scripts to workspace...`);
100
100
  const pkgJson = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf-8'));
101
101
  const scripts = {
102
- build: 'alpha build',
103
- start: 'alpha start',
104
- serve: 'alpha serve',
102
+ build: 'neutrinos build',
103
+ start: 'neutrinos start',
104
+ serve: 'neutrinos serve',
105
105
  };
106
106
  pkgJson.devDependencies = {
107
107
  lit: '^3.1.4',
package/package.json CHANGED
@@ -1,34 +1,55 @@
1
1
  {
2
2
  "name": "neutrinos-cli",
3
- "version": "1.0.0",
4
- "main": "./bin/cli.js",
3
+ "version": "1.0.2",
5
4
  "type": "module",
6
5
  "bin": {
7
- "neutrinos": "bin/cli.js"
6
+ "neutrinos": "./bin/cli.js"
8
7
  },
8
+ "main": "./bin/cli.js",
9
9
  "files": [
10
10
  ".configs",
11
+ ".env",
11
12
  "bin",
12
- "cli-auth",
13
13
  "commands",
14
- "templates",
15
14
  "utils",
15
+ "templates",
16
+ "cli-auth",
16
17
  "setup.js",
17
- ".env",
18
+ "README.md",
18
19
  "package.json"
19
20
  ],
20
21
  "publishConfig": {
21
22
  "access": "public"
22
23
  },
23
24
  "scripts": {
24
- "test": "echo \"Error: no test specified\" && exit 1",
25
- "postinstall": "node ./setup.js"
25
+ "test": "echo \"No tests yet\"",
26
+ "prepack": "npm run verify",
27
+ "verify": "node ./bin/cli.js --help || exit 1",
28
+ "setup": "node ./setup.js"
26
29
  },
27
- "author": "",
28
30
  "license": "ISC",
29
- "keywords": [],
30
- "description": "",
31
31
  "dependencies": {
32
- "fastify": "^5.4.0"
32
+ "@inquirer/checkbox": "^5.0.4",
33
+ "express": "^5.2.1",
34
+ "adm-zip": "^0.5.14",
35
+ "axios": "^1.7.2",
36
+ "change-case": "^5.4.3",
37
+ "cli-spinners": "^2.9.2",
38
+ "colorette": "^2.0.20",
39
+ "commander": "^12.0.0",
40
+ "dotenv": "^16.4.5",
41
+ "fastify": "^4.26.2",
42
+ "form-data": "^4.0.0",
43
+ "fs-extra": "^11.2.0",
44
+ "glob": "^10.3.12",
45
+ "handlebars": "^4.7.8",
46
+ "inquirer": "^9.2.17",
47
+ "open": "^10.1.0",
48
+ "openid-client": "^5.6.5",
49
+ "ora": "^8.0.1",
50
+ "prettier": "^3.2.5",
51
+ "ts-morph": "^23.0.0",
52
+ "vite": "^5.2.7",
53
+ "vitest": "^1.4.0"
33
54
  }
34
55
  }
@@ -7,7 +7,7 @@ import { copyIconToAsset } from './copy-utils.js';
7
7
  import { failed } from './logger.js';
8
8
 
9
9
  export const createZipArchive = async (directoryPath, packageName, wsPath, isModule) => {
10
- const buildCommand = `alpha build plugins ${packageName} ${isModule ? '--module' : ''}`;
10
+ const buildCommand = `neutrinos build plugins ${packageName} ${isModule ? '--module' : ''}`;
11
11
  execSync(buildCommand, {
12
12
  cwd: wsPath,
13
13
  stdio: 'inherit',
@@ -5,7 +5,7 @@ import { getPackages } from './get-packages.js';
5
5
  import { inquiry } from './inquirer-utils.js';
6
6
  import { failed } from './logger.js';
7
7
 
8
- export const getPackageMetadata = async (wsPath, packageName, pkgType = '') => {
8
+ export const getPackageMetadata = async (wsPath, packageName, pkgType = 'component') => {
9
9
  const packages = getPackages(wsPath);
10
10
 
11
11
  if (!packages.length) {
@@ -1,7 +1,14 @@
1
1
  //@ts-check
2
2
  import inquirer from 'inquirer';
3
+
4
+ /**
5
+ *
6
+ * @param {*} queries
7
+ * @returns
8
+ */
3
9
  export const inquiry = async (queries) => {
4
10
  try {
11
+ debugger;
5
12
  const answers = await inquirer.prompt(queries);
6
13
  return answers;
7
14
  } catch (error) {
@@ -10,6 +17,12 @@ export const inquiry = async (queries) => {
10
17
  }
11
18
  };
12
19
 
20
+ /**
21
+ *
22
+ * @param {*} query
23
+ * @param {*} field
24
+ * @returns
25
+ */
13
26
  export const multipleInquiry = async (query, field) => {
14
27
  const result = [];
15
28
  let addMore = true;
@@ -32,6 +45,10 @@ export const multipleInquiry = async (query, field) => {
32
45
  return result;
33
46
  };
34
47
 
48
+ /**
49
+ *
50
+ * @returns
51
+ */
35
52
  export const DISPLAY_NAME_QUERY = {
36
53
  type: 'input',
37
54
  name: 'name',