zotero-plugin-scaffold 0.0.5 → 0.0.6

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/README.md CHANGED
@@ -23,8 +23,6 @@ pnpm dlx zotero-plugin create
23
23
 
24
24
  #### From NPM
25
25
 
26
- > WIP
27
-
28
26
  ```bash
29
27
  npm install -D zotero-plugin-scaffold
30
28
 
@@ -66,7 +64,7 @@ You can import `defineConfig` in js module to get type hints. If no value is spe
66
64
  import { defineConfig } from "zotero-plugin-scaffold";
67
65
 
68
66
  export default defineConfig({
69
- placeholders: {
67
+ define: {
70
68
  addonName: "Test Addon for Zotero",
71
69
  addonID: "",
72
70
  addonRef: "",
@@ -137,7 +135,7 @@ import { Build, Config } from "zotero-plugin-scaffold";
137
135
 
138
136
  const config = await Config.loadConfig();
139
137
 
140
- const Builder = new Build(config, "production");
138
+ const Builder = new Build(config);
141
139
  await Builder.run();
142
140
  ```
143
141
 
package/dist/config.js CHANGED
@@ -28,8 +28,7 @@ export async function loadConfig(file) {
28
28
  const dotenvResult = dotenv.config({
29
29
  path: path.resolve(process.cwd(), userConfig.dotEnvPath ?? ".env"),
30
30
  }).parsed;
31
- if (!dotenvResult)
32
- throw new Error(".env file not found");
31
+ // if (!dotenvResult) throw new Error(".env file not found");
33
32
  // Load user's package.json
34
33
  const pkg = fs.readJsonSync(path.join("package.json"), {
35
34
  encoding: "utf-8",
@@ -160,11 +159,6 @@ export async function loadConfig(file) {
160
159
  },
161
160
  logLevel: "info",
162
161
  dotEnvPath: ".env",
163
- cmd: {
164
- zoteroBinPath: dotenvResult["zoteroBinPath"],
165
- profilePath: dotenvResult["profilePath"],
166
- dataDir: dotenvResult["dataDir"],
167
- },
168
162
  pkgUser: pkg,
169
163
  pkgAbsolute: path.join(path.dirname(fileURLToPath(import.meta.url)), "../"),
170
164
  };
@@ -1,6 +1,6 @@
1
1
  import { Config } from "../types.js";
2
- import Log from "./log.js";
3
- export declare abstract class LibBase {
2
+ import Log from "../utils/log.js";
3
+ export declare abstract class Base {
4
4
  config: Config;
5
5
  logger: InstanceType<typeof Log>;
6
6
  constructor(config: Config);
@@ -1,5 +1,5 @@
1
- import Log from "./log.js";
2
- export class LibBase {
1
+ import Log from "../utils/log.js";
2
+ export class Base {
3
3
  config;
4
4
  logger;
5
5
  constructor(config) {
@@ -1,6 +1,6 @@
1
1
  import { Config } from "../types.js";
2
- import { LibBase } from "../utils/libBase.js";
3
- export default class Build extends LibBase {
2
+ import { Base } from "./base.js";
3
+ export default class Build extends Base {
4
4
  private buildTime;
5
5
  private isPreRelease;
6
6
  constructor(config: Config);
package/dist/lib/build.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { generateHashSync } from "../utils/crypto.js";
2
- import { LibBase } from "../utils/libBase.js";
3
2
  import { dateFormat } from "../utils/string.js";
3
+ import { Base } from "./base.js";
4
4
  import chalk from "chalk";
5
5
  import { zip } from "compressing";
6
6
  import { buildSync } from "esbuild";
@@ -9,11 +9,12 @@ import fs from "fs-extra";
9
9
  import path from "path";
10
10
  import replaceInFile from "replace-in-file";
11
11
  const { replaceInFileSync } = replaceInFile;
12
- export default class Build extends LibBase {
12
+ export default class Build extends Base {
13
13
  buildTime;
14
14
  isPreRelease;
15
15
  constructor(config) {
16
16
  super(config);
17
+ process.env.NODE_ENV ??= "production";
17
18
  this.buildTime = "";
18
19
  this.isPreRelease = this.version.includes("-");
19
20
  }
@@ -1,7 +1,7 @@
1
1
  import { Config } from "../types.js";
2
- import { LibBase } from "../utils/libBase.js";
2
+ import { Base } from "./base.js";
3
3
  import { Octokit } from "@octokit/rest";
4
- export default class Release extends LibBase {
4
+ export default class Release extends Base {
5
5
  isCI: boolean;
6
6
  client: Octokit;
7
7
  constructor(config: Config);
@@ -1,4 +1,4 @@
1
- import { LibBase } from "../utils/libBase.js";
1
+ import { Base } from "./base.js";
2
2
  import { Octokit } from "@octokit/rest";
3
3
  import ci from "ci-info";
4
4
  import { default as glob } from "fast-glob";
@@ -7,7 +7,7 @@ import _ from "lodash";
7
7
  import mime from "mime";
8
8
  import path from "path";
9
9
  import releaseIt from "release-it";
10
- export default class Release extends LibBase {
10
+ export default class Release extends Base {
11
11
  isCI;
12
12
  client;
13
13
  constructor(config) {
@@ -1,6 +1,6 @@
1
1
  import { Config } from "../types.js";
2
- import { LibBase } from "../utils/libBase.js";
3
- export default class Serve extends LibBase {
2
+ import { Base } from "./base.js";
3
+ export default class Serve extends Base {
4
4
  private builder;
5
5
  constructor(config: Config);
6
6
  run(): Promise<void>;
package/dist/lib/serve.js CHANGED
@@ -1,4 +1,4 @@
1
- import { LibBase } from "../utils/libBase.js";
1
+ import { Base } from "./base.js";
2
2
  import Build from "./build.js";
3
3
  import { execSync, spawn } from "child_process";
4
4
  import chokidar from "chokidar";
@@ -7,10 +7,11 @@ import _ from "lodash";
7
7
  import path from "path";
8
8
  import { exit } from "process";
9
9
  import webext from "web-ext";
10
- export default class Serve extends LibBase {
10
+ export default class Serve extends Base {
11
11
  builder;
12
12
  constructor(config) {
13
13
  super(config);
14
+ process.env.NODE_ENV ??= "development";
14
15
  this.builder = new Build(config);
15
16
  }
16
17
  async run() {
@@ -90,8 +91,8 @@ export default class Serve extends LibBase {
90
91
  */
91
92
  async startZoteroWebExt() {
92
93
  await webext.cmd.run({
93
- firefox: this.config.cmd.zoteroBinPath,
94
- firefoxProfile: this.config.cmd.profilePath,
94
+ firefox: this.zoteroBinPath,
95
+ firefoxProfile: this.profilePath,
95
96
  sourceDir: path.resolve(`${this.config.dist}/addon`),
96
97
  keepProfileChanges: true,
97
98
  args: ["--debugger", "--purgecaches"],
package/dist/types.d.ts CHANGED
@@ -282,11 +282,6 @@ export interface ConfigBase {
282
282
  logLevel: "trace" | "debug" | "info" | "warn" | "error";
283
283
  }
284
284
  export interface Config extends ConfigBase {
285
- cmd: {
286
- zoteroBinPath: string;
287
- profilePath: string;
288
- dataDir: string;
289
- };
290
285
  pkgUser: any;
291
286
  pkgAbsolute: string;
292
287
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zotero-plugin-scaffold",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "A scaffold for Zotero plugin development.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {