wxt-turbo 0.1.0 → 0.3.0

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
@@ -21,7 +21,10 @@ export default defineConfig({
21
21
  modules: ['wxt-turbo'],
22
22
  turbo: {
23
23
  packageName: 'your-extension-package-name',
24
- copyFiles: [{ from: 'FIREFOX_README.md', to: 'README.md' }, 'LICENSE'],
24
+ copyFiles: [
25
+ { from: 'SOURCE_CODE_REVIEW.md', to: 'SOURCE_CODE_REVIEW.md' },
26
+ 'SOURCE_CODE_REVIEW.md',
27
+ ],
25
28
  cleanup: true, // default: true
26
29
  },
27
30
  });
@@ -32,6 +35,12 @@ export default defineConfig({
32
35
  - **Turborepo Pruning**: Automatically prunes your monorepo when running `wxt zip` to include only the necessary sources for the extension.
33
36
  - **Extra Files**: Copy extra files (like READMEs or legal docs) into the sources zip during the build process.
34
37
 
38
+ ## Publishing
39
+
40
+ Publishing a GitHub release uses `stevezhu/actions/npm-publish@v3` to run checks, build the package, and stage it on npm with provenance. Configure the repository's `NPM_TOKEN` Actions secret with permission to stage this package. The action uses pnpm 11.3.0 or later, selected by `packageManager` in `package.json`.
41
+
42
+ Review the package in npm's **Staged Packages** tab and approve it with 2FA to make the version public. You can also review it with `pnpm stage list wxt-turbo` and approve it with `pnpm stage approve <stage-id>`. The stage ID is printed in the action logs. See [npm's staged publishing documentation](https://docs.npmjs.com/staged-publishing/).
43
+
35
44
  ## License
36
45
 
37
46
  MIT
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- //#region \0rolldown/runtime.js
1
+ // \0rolldown/runtime.js
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -6,33 +6,26 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) {
13
- __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- }
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
19
15
  }
20
16
  return to;
21
17
  };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
23
19
  value: mod,
24
20
  enumerable: true
25
21
  }) : target, mod));
26
-
27
- //#endregion
28
22
  let node_fs_promises = require("node:fs/promises");
29
23
  let node_path = require("node:path");
30
24
  let is_path_inside = require("is-path-inside");
31
- is_path_inside = __toESM(is_path_inside);
25
+ is_path_inside = __toESM(is_path_inside, 1);
32
26
  let tinyexec = require("tinyexec");
33
27
  let wxt_modules = require("wxt/modules");
34
-
35
- //#region src/index.ts
28
+ // src/index.ts
36
29
  const LOGGER_PREFIX = "`[wxt-turbo]`";
37
30
  var src_default = (0, wxt_modules.defineWxtModule)({
38
31
  name: "wxt-turbo",
@@ -96,7 +89,6 @@ async function clearZipSourcesRoot(wxt) {
96
89
  force: true
97
90
  });
98
91
  }
99
-
100
- //#endregion
101
92
  module.exports = src_default;
93
+
102
94
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["fsConstants"],"sources":["../src/index.ts"],"sourcesContent":["import { constants as fsConstants, copyFile, rm } from 'node:fs/promises';\nimport { basename, join, resolve } from 'node:path';\n\nimport isPathInside from 'is-path-inside';\nimport { x } from 'tinyexec';\nimport type { Wxt } from 'wxt';\nimport { defineWxtModule } from 'wxt/modules';\n\nexport interface CopyFileConfig {\n /**\n * Source path relative to the project root or absolute path.\n */\n from: string;\n /**\n * Destination path relative to the sources zip root or absolute path.\n */\n to: string;\n}\n\nexport interface TurboModuleOptions {\n /**\n * The package name of the project to generate sources for. This needs to match the package name in the `package.json` of the project.\n */\n packageName: string;\n /**\n * Optional list of files to copy into the sources zip.\n *\n * If a string is provided, it will be copied to the zip sources at the root path.\n *\n * @example\n * [{ from: 'README.md', to: 'README.md' }, 'README.md']\n */\n copyFiles?: (CopyFileConfig | string)[];\n /**\n * Whether to clear the zip sources root directory after the zip file is created.\n *\n * @default true\n */\n cleanup?: boolean;\n}\n\ndeclare module 'wxt' {\n export interface InlineConfig {\n turbo: TurboModuleOptions;\n }\n}\n\nconst LOGGER_PREFIX = '`[wxt-turbo]`';\n\nexport default defineWxtModule<TurboModuleOptions>({\n name: 'wxt-turbo',\n configKey: 'turbo',\n async setup(wxt, options) {\n const packageName = options?.packageName;\n if (!packageName) {\n throw new Error('packageName is required');\n }\n\n // check whether turborepo is installed\n try {\n if ((await x('turbo', ['--version'])).exitCode !== 0) {\n throw new Error(`${LOGGER_PREFIX} Command failed: \\`turbo --version\\``);\n }\n wxt.logger.info(LOGGER_PREFIX, 'Turborepo detected.');\n } catch (error) {\n // https://github.com/nodejs/node/issues/46869\n if (\n error instanceof Error &&\n 'code' in error &&\n typeof error.code === 'string' &&\n error.code === 'ENOENT'\n ) {\n wxt.logger.warn(LOGGER_PREFIX, 'Turborepo is not installed');\n return;\n }\n throw error;\n }\n\n wxt.hook('config:resolved', (wxt) => {\n if (wxt.config.zip.sourcesRoot === wxt.config.root) {\n wxt.config.zip.sourcesRoot = join(\n wxt.config.outBaseDir,\n `${basename(wxt.config.outDir)}-sources`,\n );\n }\n });\n\n wxt.hook('zip:sources:start', async (wxt) => {\n await clearZipSourcesRoot(wxt);\n\n const { sourcesRoot } = wxt.config.zip;\n const absoluteSourcesRoot = resolve(wxt.config.root, sourcesRoot);\n const proc = x('turbo', [\n 'prune',\n packageName,\n '--out-dir',\n absoluteSourcesRoot,\n ]);\n proc.process?.stdout?.on('data', (data: Buffer) => {\n wxt.logger.debug(LOGGER_PREFIX, data.toString().trimEnd());\n });\n const res = await proc;\n if (res.exitCode !== 0) {\n throw new Error(res.stderr);\n }\n\n if (options.copyFiles) {\n for (const fileInfo of options.copyFiles) {\n const { absoluteFromPath, absoluteToPath } = ((\n fileInfo: CopyFileConfig | string,\n ) => {\n if (typeof fileInfo === 'string') {\n return {\n absoluteFromPath: resolve(wxt.config.root, fileInfo),\n absoluteToPath: resolve(\n absoluteSourcesRoot,\n basename(fileInfo),\n ),\n };\n }\n return {\n absoluteFromPath: resolve(wxt.config.root, fileInfo.from),\n absoluteToPath: resolve(absoluteSourcesRoot, fileInfo.to),\n };\n })(fileInfo);\n await copyFile(\n absoluteFromPath,\n absoluteToPath,\n // fail if destination file already exists\n fsConstants.COPYFILE_EXCL,\n );\n }\n }\n });\n\n wxt.hook('zip:sources:done', async (wxt) => {\n if (options.cleanup ?? true) {\n await clearZipSourcesRoot(wxt);\n }\n });\n },\n});\n\nasync function clearZipSourcesRoot(wxt: Wxt) {\n const { sourcesRoot } = wxt.config.zip;\n\n // Safety check: ensure sources root is under .output/\n const absoluteSourcesRoot = resolve(wxt.config.root, sourcesRoot);\n if (!isPathInside(absoluteSourcesRoot, wxt.config.outBaseDir)) {\n throw new Error(\n `${LOGGER_PREFIX} Sources root config must be in .output/ directory. Received: ${absoluteSourcesRoot}`,\n );\n }\n\n await rm(absoluteSourcesRoot, { recursive: true,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O;MACL,yCAA0B,IAAI,OAAO,MAAM,SAAS;MACpD,uCACE,6CACS,SAAS,CACnB;MACF;AAEH,YAAO;MACL,yCAA0B,IAAI,OAAO,MAAM,SAAS,KAAK;MACzD,uCAAwB,qBAAqB,SAAS,GAAG;MAC1D;OACA,SAAS;AACZ,yCACE,kBACA,gBAEAA,2BAAY,cACb;;IAGL;AAEF,MAAI,KAAK,oBAAoB,OAAO,QAAQ;AAC1C,OAAI,QAAQ,WAAW,KACrB,OAAM,oBAAoB,IAAI;IAEhC;;CAEL,CAAC;AAEF,eAAe,oBAAoB,KAAU;CAC3C,MAAM,EAAE,gBAAgB,IAAI,OAAO;CAGnC,MAAM,6CAA8B,IAAI,OAAO,MAAM,YAAY;AACjE,KAAI,6BAAc,qBAAqB,IAAI,OAAO,WAAW,CAC3D,OAAM,IAAI,MACR,GAAG,cAAc,gEAAgE,sBAClF;AAGH,gCAAS,qBAAqB;EAAE,WAAW;EAAM,OAAO;EAAM,CAAC"}
1
+ {"version":3,"file":"index.cjs","names":["defineWxtModule","x","join","basename","resolve","copyFile","fsConstants","isPathInside","rm"],"sources":["../src/index.ts"],"sourcesContent":["import { constants as fsConstants, copyFile, rm } from 'node:fs/promises';\nimport { basename, join, resolve } from 'node:path';\n\nimport isPathInside from 'is-path-inside';\nimport { x } from 'tinyexec';\nimport type { Wxt } from 'wxt';\nimport { defineWxtModule } from 'wxt/modules';\n\nexport interface CopyFileConfig {\n /**\n * Source path relative to the project root or absolute path.\n */\n from: string;\n /**\n * Destination path relative to the sources zip root or absolute path.\n */\n to: string;\n}\n\nexport interface TurboModuleOptions {\n /**\n * The package name of the project to generate sources for. This needs to match the package name in the `package.json` of the project.\n */\n packageName: string;\n /**\n * Optional list of files to copy into the sources zip.\n *\n * If a string is provided, it will be copied to the zip sources at the root path.\n *\n * @example\n * [{ from: 'README.md', to: 'README.md' }, 'README.md']\n */\n copyFiles?: (CopyFileConfig | string)[];\n /**\n * Whether to clear the zip sources root directory after the zip file is created.\n *\n * @default true\n */\n cleanup?: boolean;\n}\n\ndeclare module 'wxt' {\n export interface InlineConfig {\n turbo: TurboModuleOptions;\n }\n}\n\nconst LOGGER_PREFIX = '`[wxt-turbo]`';\n\nexport default defineWxtModule<TurboModuleOptions>({\n name: 'wxt-turbo',\n configKey: 'turbo',\n async setup(wxt, options) {\n const packageName = options?.packageName;\n if (!packageName) {\n throw new Error('packageName is required');\n }\n\n // check whether turborepo is installed\n try {\n if ((await x('turbo', ['--version'])).exitCode !== 0) {\n throw new Error(`${LOGGER_PREFIX} Command failed: \\`turbo --version\\``);\n }\n wxt.logger.info(LOGGER_PREFIX, 'Turborepo detected.');\n } catch (error) {\n // https://github.com/nodejs/node/issues/46869\n if (\n error instanceof Error &&\n 'code' in error &&\n typeof error.code === 'string' &&\n error.code === 'ENOENT'\n ) {\n wxt.logger.warn(LOGGER_PREFIX, 'Turborepo is not installed');\n return;\n }\n throw error;\n }\n\n wxt.hook('config:resolved', (wxt) => {\n if (wxt.config.zip.sourcesRoot === wxt.config.root) {\n wxt.config.zip.sourcesRoot = join(\n wxt.config.outBaseDir,\n `${basename(wxt.config.outDir)}-sources`,\n );\n }\n });\n\n wxt.hook('zip:sources:start', async (wxt) => {\n await clearZipSourcesRoot(wxt);\n\n const { sourcesRoot } = wxt.config.zip;\n const absoluteSourcesRoot = resolve(wxt.config.root, sourcesRoot);\n const proc = x('turbo', ['prune', packageName, '--out-dir', absoluteSourcesRoot]);\n proc.process?.stdout?.on('data', (data: Buffer) => {\n wxt.logger.debug(LOGGER_PREFIX, data.toString().trimEnd());\n });\n const res = await proc;\n if (res.exitCode !== 0) {\n throw new Error(res.stderr);\n }\n\n if (options.copyFiles) {\n for (const fileInfo of options.copyFiles) {\n const { absoluteFromPath, absoluteToPath } = ((fileInfo: CopyFileConfig | string) => {\n if (typeof fileInfo === 'string') {\n return {\n absoluteFromPath: resolve(wxt.config.root, fileInfo),\n absoluteToPath: resolve(absoluteSourcesRoot, basename(fileInfo)),\n };\n }\n return {\n absoluteFromPath: resolve(wxt.config.root, fileInfo.from),\n absoluteToPath: resolve(absoluteSourcesRoot, fileInfo.to),\n };\n })(fileInfo);\n await copyFile(\n absoluteFromPath,\n absoluteToPath,\n // fail if destination file already exists\n fsConstants.COPYFILE_EXCL,\n );\n }\n }\n });\n\n wxt.hook('zip:sources:done', async (wxt) => {\n if (options.cleanup ?? true) {\n await clearZipSourcesRoot(wxt);\n }\n });\n },\n});\n\nasync function clearZipSourcesRoot(wxt: Wxt) {\n const { sourcesRoot } = wxt.config.zip;\n\n // Safety check: ensure sources root is under .output/\n const absoluteSourcesRoot = resolve(wxt.config.root, sourcesRoot);\n if (!isPathInside(absoluteSourcesRoot, wxt.config.outBaseDir)) {\n throw new Error(\n `${LOGGER_PREFIX} Sources root config must be in .output/ directory. Received: ${absoluteSourcesRoot}`,\n );\n }\n\n await rm(absoluteSourcesRoot, { recursive: true, force: true });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAM,gBAAgB;AAEtB,IAAA,eAAA,GAAeA,YAAAA,gBAAAA,CAAoC;CACjD,MAAM;CACN,WAAW;CACX,MAAM,MAAM,KAAK,SAAS;EACxB,MAAM,cAAc,SAAS;EAC7B,IAAI,CAAC,aACH,MAAM,IAAI,MAAM,yBAAyB;EAI3C,IAAI;GACF,KAAK,OAAA,GAAMC,SAAAA,EAAAA,CAAE,SAAS,CAAC,WAAW,CAAC,EAAA,CAAG,aAAa,GACjD,MAAM,IAAI,MAAM,GAAG,cAAc,qCAAqC;GAExE,IAAI,OAAO,KAAK,eAAe,qBAAqB;EACtD,SAAS,OAAO;GAEd,IACE,iBAAiB,SACjB,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,MAAM,SAAS,UACf;IACA,IAAI,OAAO,KAAK,eAAe,4BAA4B;IAC3D;GACF;GACA,MAAM;EACR;EAEA,IAAI,KAAK,oBAAoB,QAAQ;GACnC,IAAI,IAAI,OAAO,IAAI,gBAAgB,IAAI,OA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AAO,QAAQ;GAC1C,IAAI,QAAQ,WAAW,MACrB,MAAM,oBAAoB,GAAG;EAEjC,CAAC;CACH;AACF,CAAC;AAED,eAAe,oBAAoB,KAAU;CAC3C,MAAM,EAAE,gBAAgB,IAAI,OAAO;CAGnC,MAAM,uBAAA,GAAsBF,UAAAA,QAAAA,CAAQ,IAAI,OAAO,MAAM,WAAW;CAChE,IAAI,EAAA,GAACG,eAAAA,QAAAA,CAAa,qBAAqB,IAAI,OAAO,UAAU,GAC1D,MAAM,IAAI,MACR,GAAG,cAAc,gEAAgE,qBACnF;CAGF,OAAA,GAAMC,iBAAAA,GAAAA,CAAG,qBAAqB;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;AAChE"}
package/dist/index.d.cts CHANGED
@@ -1,7 +1,4 @@
1
- import * as wxt from "wxt";
2
-
3
- //#region src/index.d.ts
4
- interface CopyFileConfig {
1
+ export interface CopyFileConfig {
5
2
  /**
6
3
  * Source path relative to the project root or absolute path.
7
4
  */
@@ -11,7 +8,7 @@ interface CopyFileConfig {
11
8
  */
12
9
  to: string;
13
10
  }
14
- interface TurboModuleOptions {
11
+ export interface TurboModuleOptions {
15
12
  /**
16
13
  * The package name of the project to generate sources for. This needs to match the package name in the `package.json` of the project.
17
14
  */
@@ -37,7 +34,5 @@ declare module 'wxt' {
37
34
  turbo: TurboModuleOptions;
38
35
  }
39
36
  }
40
- declare const _default: wxt.WxtModule<TurboModuleOptions>;
41
- //#endregion
42
- export { CopyFileConfig, TurboModuleOptions, _default as default };
43
- //# sourceMappingURL=index.d.cts.map
37
+ declare const _default: import("wxt").WxtModule<TurboModuleOptions>;
38
+ export { _default as default };
package/dist/index.d.mts CHANGED
@@ -1,7 +1,4 @@
1
- import * as wxt from "wxt";
2
-
3
- //#region src/index.d.ts
4
- interface CopyFileConfig {
1
+ export interface CopyFileConfig {
5
2
  /**
6
3
  * Source path relative to the project root or absolute path.
7
4
  */
@@ -11,7 +8,7 @@ interface CopyFileConfig {
11
8
  */
12
9
  to: string;
13
10
  }
14
- interface TurboModuleOptions {
11
+ export interface TurboModuleOptions {
15
12
  /**
16
13
  * The package name of the project to generate sources for. This needs to match the package name in the `package.json` of the project.
17
14
  */
@@ -37,7 +34,5 @@ declare module 'wxt' {
37
34
  turbo: TurboModuleOptions;
38
35
  }
39
36
  }
40
- declare const _default: wxt.WxtModule<TurboModuleOptions>;
41
- //#endregion
42
- export { CopyFileConfig, TurboModuleOptions, _default as default };
43
- //# sourceMappingURL=index.d.mts.map
37
+ declare const _default: import("wxt").WxtModule<TurboModuleOptions>;
38
+ export { _default as default };
package/dist/index.mjs CHANGED
@@ -3,8 +3,7 @@ import { basename, join, resolve } from "node:path";
3
3
  import isPathInside from "is-path-inside";
4
4
  import { x } from "tinyexec";
5
5
  import { defineWxtModule } from "wxt/modules";
6
-
7
- //#region src/index.ts
6
+ // src/index.ts
8
7
  const LOGGER_PREFIX = "`[wxt-turbo]`";
9
8
  var src_default = defineWxtModule({
10
9
  name: "wxt-turbo",
@@ -68,7 +67,6 @@ async function clearZipSourcesRoot(wxt) {
68
67
  force: true
69
68
  });
70
69
  }
71
-
72
- //#endregion
73
70
  export { src_default as default };
71
+
74
72
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["fsConstants"],"sources":["../src/index.ts"],"sourcesContent":["import { constants as fsConstants, copyFile, rm } from 'node:fs/promises';\nimport { basename, join, resolve } from 'node:path';\n\nimport isPathInside from 'is-path-inside';\nimport { x } from 'tinyexec';\nimport type { Wxt } from 'wxt';\nimport { defineWxtModule } from 'wxt/modules';\n\nexport interface CopyFileConfig {\n /**\n * Source path relative to the project root or absolute path.\n */\n from: string;\n /**\n * Destination path relative to the sources zip root or absolute path.\n */\n to: string;\n}\n\nexport interface TurboModuleOptions {\n /**\n * The package name of the project to generate sources for. This needs to match the package name in the `package.json` of the project.\n */\n packageName: string;\n /**\n * Optional list of files to copy into the sources zip.\n *\n * If a string is provided, it will be copied to the zip sources at the root path.\n *\n * @example\n * [{ from: 'README.md', to: 'README.md' }, 'README.md']\n */\n copyFiles?: (CopyFileConfig | string)[];\n /**\n * Whether to clear the zip sources root directory after the zip file is created.\n *\n * @default true\n */\n cleanup?: boolean;\n}\n\ndeclare module 'wxt' {\n export interface InlineConfig {\n turbo: TurboModuleOptions;\n }\n}\n\nconst LOGGER_PREFIX = '`[wxt-turbo]`';\n\nexport default defineWxtModule<TurboModuleOptions>({\n name: 'wxt-turbo',\n configKey: 'turbo',\n async setup(wxt, options) {\n const packageName = options?.packageName;\n if (!packageName) {\n throw new Error('packageName is required');\n }\n\n // check whether turborepo is installed\n try {\n if ((await x('turbo', ['--version'])).exitCode !== 0) {\n throw new Error(`${LOGGER_PREFIX} Command failed: \\`turbo --version\\``);\n }\n wxt.logger.info(LOGGER_PREFIX, 'Turborepo detected.');\n } catch (error) {\n // https://github.com/nodejs/node/issues/46869\n if (\n error instanceof Error &&\n 'code' in error &&\n typeof error.code === 'string' &&\n error.code === 'ENOENT'\n ) {\n wxt.logger.warn(LOGGER_PREFIX, 'Turborepo is not installed');\n return;\n }\n throw error;\n }\n\n wxt.hook('config:resolved', (wxt) => {\n if (wxt.config.zip.sourcesRoot === wxt.config.root) {\n wxt.config.zip.sourcesRoot = join(\n wxt.config.outBaseDir,\n `${basename(wxt.config.outDir)}-sources`,\n );\n }\n });\n\n wxt.hook('zip:sources:start', async (wxt) => {\n await clearZipSourcesRoot(wxt);\n\n const { sourcesRoot } = wxt.config.zip;\n const absoluteSourcesRoot = resolve(wxt.config.root, sourcesRoot);\n const proc = x('turbo', [\n 'prune',\n packageName,\n '--out-dir',\n absoluteSourcesRoot,\n ]);\n proc.process?.stdout?.on('data', (data: Buffer) => {\n wxt.logger.debug(LOGGER_PREFIX, data.toString().trimEnd());\n });\n const res = await proc;\n if (res.exitCode !== 0) {\n throw new Error(res.stderr);\n }\n\n if (options.copyFiles) {\n for (const fileInfo of options.copyFiles) {\n const { absoluteFromPath, absoluteToPath } = ((\n fileInfo: CopyFileConfig | string,\n ) => {\n if (typeof fileInfo === 'string') {\n return {\n absoluteFromPath: resolve(wxt.config.root, fileInfo),\n absoluteToPath: resolve(\n absoluteSourcesRoot,\n basename(fileInfo),\n ),\n };\n }\n return {\n absoluteFromPath: resolve(wxt.config.root, fileInfo.from),\n absoluteToPath: resolve(absoluteSourcesRoot, fileInfo.to),\n };\n })(fileInfo);\n await copyFile(\n absoluteFromPath,\n absoluteToPath,\n // fail if destination file already exists\n fsConstants.COPYFILE_EXCL,\n );\n }\n }\n });\n\n wxt.hook('zip:sources:done', async (wxt) => {\n if (options.cleanup ?? true) {\n await clearZipSourcesRoot(wxt);\n }\n });\n },\n});\n\nasync function clearZipSourcesRoot(wxt: Wxt) {\n const { sourcesRoot } = wxt.config.zip;\n\n // Safety check: ensure sources root is under .output/\n const absoluteSourcesRoot = resolve(wxt.config.root, sourcesRoot);\n if (!isPathInside(absoluteSourcesRoot, wxt.config.outBaseDir)) {\n throw new Error(\n `${LOGGER_PREFIX} Sources root config must be in .output/ directory. Received: ${absoluteSourcesRoot}`,\n );\n }\n\n await rm(absoluteSourcesRoot, { recursive: true, force: true });\n}\n"],"mappings":";;;;;;;AA+CA,MAAM,gBAAgB;AAEtB,kBAAe,gBAAoC;CACjD,MAAM;CACN,WAAW;CACX,MAAM,MAAM,KAAK,SAAS;EACxB,MAAM,cAAc,SAAS;AAC7B,MAAI,CAAC,YACH,OAAM,IAAI,MAAM,0BAA0B;AAI5C,MAAI;AACF,QAAK,MAAM,EAAE,SAAS,CAAC,YAAY,CAAC,EAAE,aAAa,EACjD,OAAM,IAAI,MAAM,GAAG,cAAc,sCAAsC;AAEzE,OAAI,OAAO,KAAK,eAAe,sBAAsB;WAC9C,OAAO;AAEd,OACE,iBAAiB,SACjB,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,MAAM,SAAS,UACf;AACA,QAAI,OAAO,KAAK,eAAe,6BAA6B;AAC5D;;AAEF,SAAM;;AAGR,MAAI,KAAK,o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a,qBAAqB,IAAI,OAAO,WAAW,CAC3D,OAAM,IAAI,MACR,GAAG,cAAc,gEAAgE,sBAClF;AAGH,OAAM,GAAG,qBAAqB;EAAE,WAAW;EAAM,OAAO;EAAM,CAAC"}
1
+ {"version":3,"file":"index.mjs","names":["fsConstants"],"sources":["../src/index.ts"],"sourcesContent":["import { constants as fsConstants, copyFile, rm } from 'node:fs/promises';\nimport { basename, join, resolve } from 'node:path';\n\nimport isPathInside from 'is-path-inside';\nimport { x } from 'tinyexec';\nimport type { Wxt } from 'wxt';\nimport { defineWxtModule } from 'wxt/modules';\n\nexport interface CopyFileConfig {\n /**\n * Source path relative to the project root or absolute path.\n */\n from: string;\n /**\n * Destination path relative to the sources zip root or absolute path.\n */\n to: string;\n}\n\nexport interface TurboModuleOptions {\n /**\n * The package name of the project to generate sources for. This needs to match the package name in the `package.json` of the project.\n */\n packageName: string;\n /**\n * Optional list of files to copy into the sources zip.\n *\n * If a string is provided, it will be copied to the zip sources at the root path.\n *\n * @example\n * [{ from: 'README.md', to: 'README.md' }, 'README.md']\n */\n copyFiles?: (CopyFileConfig | string)[];\n /**\n * Whether to clear the zip sources root directory after the zip file is created.\n *\n * @default true\n */\n cleanup?: boolean;\n}\n\ndeclare module 'wxt' {\n export interface InlineConfig {\n turbo: TurboModuleOptions;\n }\n}\n\nconst LOGGER_PREFIX = '`[wxt-turbo]`';\n\nexport default defineWxtModule<TurboModuleOptions>({\n name: 'wxt-turbo',\n configKey: 'turbo',\n async setup(wxt, options) {\n const packageName = options?.packageName;\n if (!packageName) {\n throw new Error('packageName is required');\n }\n\n // check whether turborepo is installed\n try {\n if ((await x('turbo', ['--version'])).exitCode !== 0) {\n throw new Error(`${LOGGER_PREFIX} Command failed: \\`turbo --version\\``);\n }\n wxt.logger.info(LOGGER_PREFIX, 'Turborepo detected.');\n } catch (error) {\n // https://github.com/nodejs/node/issues/46869\n if (\n error instanceof Error &&\n 'code' in error &&\n typeof error.code === 'string' &&\n error.code === 'ENOENT'\n ) {\n wxt.logger.warn(LOGGER_PREFIX, 'Turborepo is not installed');\n return;\n }\n throw error;\n }\n\n wxt.hook('config:resolved', (wxt) => {\n if (wxt.config.zip.sourcesRoot === wxt.config.root) {\n wxt.config.zip.sourcesRoot = join(\n wxt.config.outBaseDir,\n `${basename(wxt.config.outDir)}-sources`,\n );\n }\n });\n\n wxt.hook('zip:sources:start', async (wxt) => {\n await clearZipSourcesRoot(wxt);\n\n const { sourcesRoot } = wxt.config.zip;\n const absoluteSourcesRoot = resolve(wxt.config.root, sourcesRoot);\n const proc = x('turbo', ['prune', packageName, '--out-dir', absoluteSourcesRoot]);\n proc.process?.stdout?.on('data', (data: Buffer) => {\n wxt.logger.debug(LOGGER_PREFIX, data.toString().trimEnd());\n });\n const res = await proc;\n if (res.exitCode !== 0) {\n throw new Error(res.stderr);\n }\n\n if (options.copyFiles) {\n for (const fileInfo of options.copyFiles) {\n const { absoluteFromPath, absoluteToPath } = ((fileInfo: CopyFileConfig | string) => {\n if (typeof fileInfo === 'string') {\n return {\n absoluteFromPath: resolve(wxt.config.root, fileInfo),\n absoluteToPath: resolve(absoluteSourcesRoot, basename(fileInfo)),\n };\n }\n return {\n absoluteFromPath: resolve(wxt.config.root, fileInfo.from),\n absoluteToPath: resolve(absoluteSourcesRoot, fileInfo.to),\n };\n })(fileInfo);\n await copyFile(\n absoluteFromPath,\n absoluteToPath,\n // fail if destination file already exists\n fsConstants.COPYFILE_EXCL,\n );\n }\n }\n });\n\n wxt.hook('zip:sources:done', async (wxt) => {\n if (options.cleanup ?? true) {\n await clearZipSourcesRoot(wxt);\n }\n });\n },\n});\n\nasync function clearZipSourcesRoot(wxt: Wxt) {\n const { sourcesRoot } = wxt.config.zip;\n\n // Safety check: ensure sources root is under .output/\n const absoluteSourcesRoot = resolve(wxt.config.root, sourcesRoot);\n if (!isPathInside(absoluteSourcesRoot, wxt.config.outBaseDir)) {\n throw new Error(\n `${LOGGER_PREFIX} Sources root config must be in .output/ directory. Received: ${absolu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AK,MAAM,YAAY,QAAQ,WAAW;IACxC,MAAM,EAAE,kBAAkB,qBAAqB,aAAsC;KACnF,IAAI,OAAO,aAAa,UACtB,OAAO;MACL,kBAAkB,QAAQ,IAAI,OAAO,MAAM,QAAQ;MACnD,gBAAgB,QAAQ,qBAAqB,SAAS,QAAQ,CAAC;KACjE;KAEF,OAAO;MACL,kBAAkB,QAAQ,IAAI,OAAO,MAAM,SAAS,IAAI;MACxD,gBAAgB,QAAQ,qBAAqB,SAAS,EAAE;KAC1D;IACF,EAAA,CAAG,QAAQ;IACX,MAAM,SACJ,kBACA,gBAEAA,UAAY,aACd;GACF;EAEJ,CAAC;EAED,IAAI,KAAK,oBAAoB,OAAO,QAAQ;GAC1C,IAAI,QAAQ,WAAW,MACrB,MAAM,oBAAoB,GAAG;EAEjC,CAAC;CACH;AACF,CAAC;AAED,eAAe,oBAAoB,KAAU;CAC3C,MAAM,EAAE,gBAAgB,IAAI,OAAO;CAGnC,MAAM,sBAAsB,QAAQ,IAAI,OAAO,MAAM,WAAW;CAChE,IAAI,CAAC,aAAa,qBAAqB,IAAI,OAAO,UAAU,GAC1D,MAAM,IAAI,MACR,GAAG,cAAc,gEAAgE,qBACnF;CAGF,MAAM,GAAG,qBAAqB;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;AAChE"}
package/package.json CHANGED
@@ -1,20 +1,26 @@
1
1
  {
2
2
  "name": "wxt-turbo",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "WXT module for Turborepo integration",
5
5
  "keywords": [
6
- "wxt",
7
- "wxt-module",
6
+ "turbo",
8
7
  "turborepo",
9
- "turbo"
8
+ "wxt",
9
+ "wxt-module"
10
10
  ],
11
+ "license": "MIT",
12
+ "author": "Steve Zhu <4130171+stevezhu@users.noreply.github.com>",
11
13
  "repository": {
12
14
  "type": "git",
13
15
  "url": "git+https://github.com/stevezhu/wxt-turbo.git"
14
16
  },
15
- "license": "MIT",
16
- "author": "Steve Zhu <4130171+stevezhu@users.noreply.github.com>",
17
+ "files": [
18
+ "dist/*"
19
+ ],
17
20
  "type": "module",
21
+ "main": "./dist/index.cjs",
22
+ "module": "./dist/index.mjs",
23
+ "types": "./dist/index.d.mts",
18
24
  "exports": {
19
25
  ".": {
20
26
  "types": "./dist/index.d.mts",
@@ -22,37 +28,29 @@
22
28
  "import": "./dist/index.mjs"
23
29
  }
24
30
  },
25
- "main": "./dist/index.cjs",
26
- "module": "./dist/index.mjs",
27
- "types": "./dist/index.d.mts",
28
- "files": [
29
- "dist/*"
30
- ],
31
- "scripts": {
32
- "build": "tsdown",
33
- "format": "prettier -w . && eslint . --fix",
34
- "lint": "prettier -c . && eslint .",
35
- "test": "tsc --noEmit"
36
- },
37
31
  "dependencies": {
38
32
  "is-path-inside": "^4.0.0",
39
- "tinyexec": "^1.0.2"
33
+ "tinyexec": "^1.3.1"
40
34
  },
41
35
  "devDependencies": {
42
- "@stzhu/eslint-config": "^0.9.0",
43
- "@stzhu/tsconfig": "^0.1.1",
44
- "@types/node": "^25.0.3",
45
- "eslint": "^9.39.2",
46
- "prettier": "^3.8.1",
47
- "prettier-plugin-packagejson": "^3.0.0",
48
- "tsdown": "^0.20.3",
49
- "typescript": "^5.9.3"
36
+ "@stzhu/tsconfig": "^0.5.0",
37
+ "@types/node": "^26.6.6",
38
+ "oxfmt": "^0.77.0",
39
+ "oxlint": "^1.92.0",
40
+ "oxlint-tsgolint": "^7.0.2006",
41
+ "tsdown": "^0.23.7",
42
+ "typescript": "^7.0.2"
50
43
  },
51
44
  "peerDependencies": {
52
- "wxt": "^0.20.0"
45
+ "wxt": "^0.21.5"
53
46
  },
54
- "packageManager": "pnpm@10.28.2",
55
47
  "engines": {
56
- "node": ">=20"
48
+ "node": ">=24"
49
+ },
50
+ "scripts": {
51
+ "build": "tsdown",
52
+ "format": "oxlint --fix . && oxfmt --write .",
53
+ "lint": "oxfmt --check . && oxlint .",
54
+ "test": "tsc --noEmit"
57
55
  }
58
- }
56
+ }