@blastlauncher/cli 1.0.1 → 1.0.3

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @blastlauncher/cli
2
2
 
3
+ ## 1.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix package should run build before publish
8
+
9
+ ## 1.0.2
10
+
11
+ ### Patch Changes
12
+
13
+ - Run build in publish command
14
+
3
15
  ## 1.0.1
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -257,17 +257,19 @@ var PackageVersionHelper = class {
257
257
  return packageName;
258
258
  }
259
259
  };
260
- async function publishExtensions(extensionFolder, npmOrganization, npmRegistry) {
260
+ async function publishExtensions(extensionFolder, npmOrganization, npmRegistry, distDir) {
261
261
  const versionHelper = new PackageVersionHelper(npmOrganization, npmRegistry);
262
262
  console.log(`
263
263
  Entering ${extensionFolder}
264
264
  `);
265
265
  (0, import_child_process.execSync)(`cd "${extensionFolder}"`);
266
- const distDir = import_path.default.resolve(extensionFolder, "dist");
266
+ if (!distDir) {
267
+ distDir = import_path.default.resolve(extensionFolder, "dist");
268
+ }
267
269
  if (!import_fs_extra.default.existsSync(distDir)) {
268
- console.error(`dist directory does not exist at ${distDir}`);
269
- process.exit(1);
270
+ import_fs_extra.default.mkdirSync(distDir);
270
271
  }
272
+ await buildExtension(extensionFolder, distDir);
271
273
  const packageName = versionHelper.getPackageName(extensionFolder);
272
274
  let version = await versionHelper.getPackageVersion(packageName);
273
275
  if (version) {
@@ -294,6 +296,9 @@ function getTSConfigPath(extensionDir) {
294
296
  }
295
297
  async function buildExtension(extensionDir, outputFolder) {
296
298
  const packageJson = JSON.parse(import_fs_extra.default.readFileSync(import_path.default.resolve(extensionDir, "package.json"), "utf8"));
299
+ if (!outputFolder) {
300
+ outputFolder = import_path.default.resolve(extensionDir, "dist");
301
+ }
297
302
  const commandNames = packageJson.commands.map((command) => command.name);
298
303
  const supportedExts = [".js", ".ts", ".tsx", ".jsx"];
299
304
  const tsconfigPath = getTSConfigPath(extensionDir);
@@ -313,7 +318,7 @@ async function buildExtension(extensionDir, outputFolder) {
313
318
  output: outputPath
314
319
  };
315
320
  });
316
- console.info(`entry points [${esbuildConfigs.map((config) => config.input).join(", ")}]`);
321
+ console.info(`entry points [${esbuildConfigs.map((config) => config.input).join(" ")}]`);
317
322
  for (const config of esbuildConfigs) {
318
323
  await import_esbuild.default.build({
319
324
  entryPoints: [config.input],
@@ -350,10 +355,10 @@ program.name("blast-cli").description(`CLI for Blast Launcher
350
355
  Example Usage:
351
356
  blast build ./extensions/todo-list -o ./extensions/todo-list/dist
352
357
  blast publish ./extensions/todo-list blast-extensions`);
353
- program.command("publish").description("Publish extensions").argument("<path>", "Path to extensions folder").argument("<organization>", "NPM organization to publish to, e.g. blast-extensions").option("-r, --registry <registry>", "NPM registry to publish to", "https://registry.npmjs.org").action((dir, organization, options) => {
354
- return publishExtensions(dir, organization, options.registry);
358
+ program.command("publish").description("Publish extensions").argument("<path>", "Path to extensions folder").argument("<organization>", "NPM organization to publish to, e.g. blast-extensions").option("-r, --registry <registry>", "NPM registry to publish to", "https://registry.npmjs.org").option("-o, --output <output>", "Output directory, default to ./dist folder relative to extension path").action((dir, organization, options) => {
359
+ return publishExtensions(dir, organization, options.registry, options.output);
355
360
  });
356
- program.command("build").description("Build extensions").argument("<path>", "Path to extension").option("-o, --output <output>", "Output directory").action((path3, options) => {
361
+ program.command("build").description("Build extensions").argument("<path>", "Path to extension").option("-o, --output <output>", "Output directory, default to ./dist folder relative to extension path").action((path3, options) => {
357
362
  return buildExtension(path3, options.output);
358
363
  });
359
364
  program.parse();
package/index.js CHANGED
@@ -86,20 +86,24 @@ class PackageVersionHelper {
86
86
  * @param {string} extensionFolder
87
87
  * @param {string} npmOrganization
88
88
  * @param {string} npmRegistry
89
+ * @param {string} distDir
89
90
  */
90
- async function publishExtensions(extensionFolder, npmOrganization, npmRegistry) {
91
+ async function publishExtensions(extensionFolder, npmOrganization, npmRegistry, distDir) {
91
92
  const versionHelper = new PackageVersionHelper(npmOrganization, npmRegistry);
92
93
 
93
94
  console.log(`\nEntering ${extensionFolder}\n`);
94
95
  execSync(`cd "${extensionFolder}"`);
95
96
 
96
- const distDir = path.resolve(extensionFolder, "dist");
97
+ if (!distDir) {
98
+ distDir = path.resolve(extensionFolder, "dist");
99
+ }
97
100
 
98
101
  if (!fs.existsSync(distDir)) {
99
- console.error(`dist directory does not exist at ${distDir}`);
100
- process.exit(1);
102
+ fs.mkdirSync(distDir);
101
103
  }
102
104
 
105
+ await buildExtension(extensionFolder, distDir);
106
+
103
107
  const packageName = versionHelper.getPackageName(extensionFolder);
104
108
  let version = await versionHelper.getPackageVersion(packageName);
105
109
  if (version) {
@@ -137,6 +141,9 @@ function getTSConfigPath(extensionDir) {
137
141
  async function buildExtension(extensionDir, outputFolder) {
138
142
  // Gather entry points from target extension's packages.json
139
143
  const packageJson = JSON.parse(fs.readFileSync(path.resolve(extensionDir, "package.json"), "utf8"));
144
+ if (!outputFolder) {
145
+ outputFolder = path.resolve(extensionDir, "dist");
146
+ }
140
147
 
141
148
  const commandNames = packageJson.commands.map((command) => command.name);
142
149
 
@@ -165,7 +172,7 @@ async function buildExtension(extensionDir, outputFolder) {
165
172
  };
166
173
  });
167
174
 
168
- console.info(`entry points [${esbuildConfigs.map((config) => config.input).join(", ")}]`);
175
+ console.info(`entry points [${esbuildConfigs.map((config) => config.input).join(" ")}]`);
169
176
 
170
177
  // Build each entry point
171
178
  for (const config of esbuildConfigs) {
@@ -233,15 +240,16 @@ program
233
240
  .argument("<path>", "Path to extensions folder")
234
241
  .argument("<organization>", "NPM organization to publish to, e.g. blast-extensions")
235
242
  .option("-r, --registry <registry>", "NPM registry to publish to", "https://registry.npmjs.org")
243
+ .option("-o, --output <output>", "Output directory, default to ./dist folder relative to extension path")
236
244
  .action((dir, organization, options) => {
237
- return publishExtensions(dir, organization, options.registry);
245
+ return publishExtensions(dir, organization, options.registry, options.output);
238
246
  });
239
247
 
240
248
  program
241
249
  .command("build")
242
250
  .description("Build extensions")
243
251
  .argument("<path>", "Path to extension")
244
- .option("-o, --output <output>", "Output directory")
252
+ .option("-o, --output <output>", "Output directory, default to ./dist folder relative to extension path")
245
253
  .action((path, options) => {
246
254
  return buildExtension(path, options.output);
247
255
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blastlauncher/cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Blast CLI Tools",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {