zotero-plugin-scaffold 0.0.9 → 0.0.10

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/dist/cli.mjs CHANGED
@@ -23,7 +23,7 @@ import 'chokidar';
23
23
  import 'process';
24
24
 
25
25
  const name = "zotero-plugin-scaffold";
26
- const version = "0.0.9";
26
+ const version = "0.0.10";
27
27
  const description = "A scaffold for Zotero plugin development.";
28
28
  const scripts = {
29
29
  dev: "unbuild --stub",
package/dist/index.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  import { loadConfig as loadConfig$1 } from 'c12';
2
- import * as fs from 'fs-extra';
3
- import fs__default from 'fs-extra';
2
+ import fs from 'fs-extra';
4
3
  import { createHooks } from 'hookable';
5
4
  import path from 'path';
6
5
  import { dash, template, assign, debounce } from 'radash';
@@ -55,7 +54,7 @@ async function loadConfig(overrides) {
55
54
  return resolveConfig(result.config);
56
55
  }
57
56
  function resolveConfig(config) {
58
- const pkg = fs__default.readJsonSync(path.join("package.json"), {
57
+ const pkg = fs.readJsonSync(path.join("package.json"), {
59
58
  encoding: "utf-8"
60
59
  }), [, owner, repo] = (pkg.repository?.url ?? "").match(
61
60
  /:\/\/github.com\/([^/]+)\/([^.]+)\.git$/
@@ -243,7 +242,7 @@ class Build extends Base {
243
242
  `Building version ${chalk.blue(this.version)} to ${chalk.blue(this.dist)} at ${chalk.blue(this.buildTime)} in ${chalk.blue(process.env.NODE_ENV)} mode.`
244
243
  );
245
244
  await this.ctx.hooks.callHook("build:init", this.ctx);
246
- fs__default.emptyDirSync(this.dist);
245
+ fs.emptyDirSync(this.dist);
247
246
  await this.ctx.hooks.callHook("build:mkdir", this.ctx);
248
247
  this.copyAssets();
249
248
  await this.ctx.hooks.callHook("build:copyAssets", this.ctx);
@@ -281,13 +280,13 @@ class Build extends Base {
281
280
  files.forEach((file) => {
282
281
  const newPath = `${this.dist}/addon/${file.replace(new RegExp(this.src.join("|")), "")}`;
283
282
  this.logger.debug(`Copy ${file} to ${newPath}`);
284
- fs__default.copySync(file, newPath);
283
+ fs.copySync(file, newPath);
285
284
  });
286
285
  }
287
286
  makeManifest() {
288
287
  if (!this.ctx.build.makeManifest.enable)
289
288
  return;
290
- const userData = fs__default.readJSONSync(
289
+ const userData = fs.readJSONSync(
291
290
  `${this.dist}/addon/manifest.json`
292
291
  ), template2 = {
293
292
  ...userData,
@@ -308,7 +307,7 @@ class Build extends Base {
308
307
  };
309
308
  const data = assign(userData, template2);
310
309
  this.logger.debug("manifest: ", JSON.stringify(data, null, 2));
311
- fs__default.outputJSONSync(`${this.dist}/addon/manifest.json`, data, { spaces: 2 });
310
+ fs.outputJSONSync(`${this.dist}/addon/manifest.json`, data, { spaces: 2 });
312
311
  }
313
312
  /**
314
313
  * Replace all `placeholder.key` to `placeholder.value` for all files in `dist`
@@ -354,7 +353,7 @@ class Build extends Base {
354
353
  for (const localeName of localeNames) {
355
354
  if (this.ctx.build.fluent.prefixLocaleFiles == true) {
356
355
  glob.sync(`${this.dist}/addon/locale/${localeName}/**/*.ftl`, {}).forEach((f) => {
357
- fs__default.moveSync(
356
+ fs.moveSync(
358
357
  f,
359
358
  `${path.dirname(f)}/${this.namespace}-${path.basename(f)}`
360
359
  );
@@ -396,7 +395,7 @@ class Build extends Base {
396
395
  });
397
396
  }
398
397
  makeUpdateJson() {
399
- const manifest = fs__default.readJSONSync(
398
+ const manifest = fs.readJSONSync(
400
399
  `${this.dist}/addon/manifest.json`
401
400
  ), min = manifest.applications?.zotero?.strict_min_version, max = manifest.applications?.zotero?.strict_max_version;
402
401
  const updateHash = generateHashSync(
@@ -425,8 +424,8 @@ class Build extends Base {
425
424
  }
426
425
  }
427
426
  };
428
- fs__default.writeJsonSync(`${this.dist}/update-beta.json`, data, { spaces: 2 });
429
- !this.isPreRelease ? fs__default.writeJsonSync(`${this.dist}/update.json`, data, { spaces: 2 }) : "pass";
427
+ fs.writeJsonSync(`${this.dist}/update-beta.json`, data, { spaces: 2 });
428
+ !this.isPreRelease ? fs.writeJsonSync(`${this.dist}/update.json`, data, { spaces: 2 }) : "pass";
430
429
  this.logger.log(
431
430
  `Prepare Update.json for ${this.isPreRelease ? "\x1B[31m Prerelease \x1B[0m" : "\x1B[32m Release \x1B[0m"}`
432
431
  );
@@ -529,10 +528,10 @@ class Release extends Base {
529
528
  owner: this.owner,
530
529
  repo: this.repo,
531
530
  release_id: releaseID,
532
- data: fs__default.readFileSync(asset),
531
+ data: fs.readFileSync(asset),
533
532
  headers: {
534
533
  "content-type": mime.getType(asset) || "application/octet-stream",
535
- "content-length": fs__default.statSync(asset).size
534
+ "content-length": fs.statSync(asset).size
536
535
  },
537
536
  name: path.basename(asset)
538
537
  }).then((res) => {
@@ -672,9 +671,9 @@ class Serve extends Base {
672
671
  process.on("SIGINT", () => {
673
672
  this.exit();
674
673
  });
675
- if (!fs__default.existsSync(this.zoteroBinPath))
674
+ if (!fs.existsSync(this.zoteroBinPath))
676
675
  throw new Error("The Zotero binary not found.");
677
- if (!fs__default.existsSync(this.profilePath))
676
+ if (!fs.existsSync(this.profilePath))
678
677
  throw new Error("The Zotero profile not found.");
679
678
  await this.ctx.hooks.callHook("serve:init", this.ctx);
680
679
  await this.builder.run();
@@ -732,10 +731,10 @@ ${path2} changed`);
732
731
  }
733
732
  async startZotero() {
734
733
  let isZoteroReady = false;
735
- if (!fs__default.existsSync(this.zoteroBinPath)) {
734
+ if (!fs.existsSync(this.zoteroBinPath)) {
736
735
  throw new Error("Zotero binary does not exist.");
737
736
  }
738
- if (!fs__default.existsSync(this.profilePath)) {
737
+ if (!fs.existsSync(this.profilePath)) {
739
738
  throw new Error("The given Zotero profile does not exist.");
740
739
  }
741
740
  this.prepareDevEnv();
@@ -794,8 +793,8 @@ ${path2} changed`);
794
793
  `extensions/${this.id}`
795
794
  );
796
795
  const buildPath = path.resolve("build/addon");
797
- if (!fs__default.existsSync(addonProxyFilePath) || fs__default.readFileSync(addonProxyFilePath, "utf-8") !== buildPath) {
798
- fs__default.writeFileSync(addonProxyFilePath, buildPath);
796
+ if (!fs.existsSync(addonProxyFilePath) || fs.readFileSync(addonProxyFilePath, "utf-8") !== buildPath) {
797
+ fs.writeFileSync(addonProxyFilePath, buildPath);
799
798
  this.logger.debug(
800
799
  `Addon proxy file has been updated.
801
800
  File path: ${addonProxyFilePath}
@@ -806,12 +805,12 @@ ${path2} changed`);
806
805
  this.profilePath,
807
806
  `extensions/${this.id}.xpi`
808
807
  );
809
- if (fs__default.existsSync(addonXpiFilePath)) {
810
- fs__default.rmSync(addonXpiFilePath);
808
+ if (fs.existsSync(addonXpiFilePath)) {
809
+ fs.rmSync(addonXpiFilePath);
811
810
  }
812
811
  const prefsPath = path.join(this.profilePath, "prefs.js");
813
- if (fs__default.existsSync(prefsPath)) {
814
- const PrefsLines = fs__default.readFileSync(prefsPath, "utf-8").split("\n");
812
+ if (fs.existsSync(prefsPath)) {
813
+ const PrefsLines = fs.readFileSync(prefsPath, "utf-8").split("\n");
815
814
  const filteredLines = PrefsLines.map((line) => {
816
815
  if (line.includes("extensions.lastAppBuildId") || line.includes("extensions.lastAppVersion")) {
817
816
  return;
@@ -822,7 +821,7 @@ ${path2} changed`);
822
821
  return line;
823
822
  });
824
823
  const updatedPrefs = filteredLines.join("\n");
825
- fs__default.writeFileSync(prefsPath, updatedPrefs, "utf-8");
824
+ fs.writeFileSync(prefsPath, updatedPrefs, "utf-8");
826
825
  this.logger.debug("The <profile>/prefs.js has been modified.");
827
826
  }
828
827
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zotero-plugin-scaffold",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "A scaffold for Zotero plugin development.",
5
5
  "type": "module",
6
6
  "exports": {