unplugin-env 0.1.4 → 0.1.5

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/webpack.cjs CHANGED
@@ -561,7 +561,7 @@ var require_to_regex_range = __commonJS({
561
561
  if (start === stop) {
562
562
  return { pattern: start, count: [], digits: 0 };
563
563
  }
564
- let zipped = zip2(start, stop);
564
+ let zipped = zip(start, stop);
565
565
  let digits = zipped.length;
566
566
  let pattern = "";
567
567
  let count = 0;
@@ -621,7 +621,7 @@ var require_to_regex_range = __commonJS({
621
621
  }
622
622
  return result;
623
623
  }
624
- function zip2(a, b) {
624
+ function zip(a, b) {
625
625
  let arr = [];
626
626
  for (let i = 0; i < a.length; i++)
627
627
  arr.push([a[i], b[i]]);
@@ -3443,8 +3443,8 @@ var require_utils3 = __commonJS({
3443
3443
  exports2.array = array;
3444
3444
  var errno = require_errno();
3445
3445
  exports2.errno = errno;
3446
- var fs3 = require_fs();
3447
- exports2.fs = fs3;
3446
+ var fs4 = require_fs();
3447
+ exports2.fs = fs4;
3448
3448
  var path2 = require_path();
3449
3449
  exports2.path = path2;
3450
3450
  var pattern = require_pattern();
@@ -3628,12 +3628,12 @@ var require_fs2 = __commonJS({
3628
3628
  "use strict";
3629
3629
  Object.defineProperty(exports2, "__esModule", { value: true });
3630
3630
  exports2.createFileSystemAdapter = exports2.FILE_SYSTEM_ADAPTER = void 0;
3631
- var fs3 = require("fs");
3631
+ var fs4 = require("fs");
3632
3632
  exports2.FILE_SYSTEM_ADAPTER = {
3633
- lstat: fs3.lstat,
3634
- stat: fs3.stat,
3635
- lstatSync: fs3.lstatSync,
3636
- statSync: fs3.statSync
3633
+ lstat: fs4.lstat,
3634
+ stat: fs4.stat,
3635
+ lstatSync: fs4.lstatSync,
3636
+ statSync: fs4.statSync
3637
3637
  };
3638
3638
  function createFileSystemAdapter(fsMethods) {
3639
3639
  if (fsMethods === void 0) {
@@ -3650,12 +3650,12 @@ var require_settings = __commonJS({
3650
3650
  "node_modules/.pnpm/@nodelib+fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/settings.js"(exports2) {
3651
3651
  "use strict";
3652
3652
  Object.defineProperty(exports2, "__esModule", { value: true });
3653
- var fs3 = require_fs2();
3653
+ var fs4 = require_fs2();
3654
3654
  var Settings = class {
3655
3655
  constructor(_options = {}) {
3656
3656
  this._options = _options;
3657
3657
  this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true);
3658
- this.fs = fs3.createFileSystemAdapter(this._options.fs);
3658
+ this.fs = fs4.createFileSystemAdapter(this._options.fs);
3659
3659
  this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false);
3660
3660
  this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
3661
3661
  }
@@ -3815,8 +3815,8 @@ var require_utils4 = __commonJS({
3815
3815
  "use strict";
3816
3816
  Object.defineProperty(exports2, "__esModule", { value: true });
3817
3817
  exports2.fs = void 0;
3818
- var fs3 = require_fs3();
3819
- exports2.fs = fs3;
3818
+ var fs4 = require_fs3();
3819
+ exports2.fs = fs4;
3820
3820
  }
3821
3821
  });
3822
3822
 
@@ -4011,14 +4011,14 @@ var require_fs4 = __commonJS({
4011
4011
  "use strict";
4012
4012
  Object.defineProperty(exports2, "__esModule", { value: true });
4013
4013
  exports2.createFileSystemAdapter = exports2.FILE_SYSTEM_ADAPTER = void 0;
4014
- var fs3 = require("fs");
4014
+ var fs4 = require("fs");
4015
4015
  exports2.FILE_SYSTEM_ADAPTER = {
4016
- lstat: fs3.lstat,
4017
- stat: fs3.stat,
4018
- lstatSync: fs3.lstatSync,
4019
- statSync: fs3.statSync,
4020
- readdir: fs3.readdir,
4021
- readdirSync: fs3.readdirSync
4016
+ lstat: fs4.lstat,
4017
+ stat: fs4.stat,
4018
+ lstatSync: fs4.lstatSync,
4019
+ statSync: fs4.statSync,
4020
+ readdir: fs4.readdir,
4021
+ readdirSync: fs4.readdirSync
4022
4022
  };
4023
4023
  function createFileSystemAdapter(fsMethods) {
4024
4024
  if (fsMethods === void 0) {
@@ -4037,12 +4037,12 @@ var require_settings2 = __commonJS({
4037
4037
  Object.defineProperty(exports2, "__esModule", { value: true });
4038
4038
  var path2 = require("path");
4039
4039
  var fsStat = require_out();
4040
- var fs3 = require_fs4();
4040
+ var fs4 = require_fs4();
4041
4041
  var Settings = class {
4042
4042
  constructor(_options = {}) {
4043
4043
  this._options = _options;
4044
4044
  this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
4045
- this.fs = fs3.createFileSystemAdapter(this._options.fs);
4045
+ this.fs = fs4.createFileSystemAdapter(this._options.fs);
4046
4046
  this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path2.sep);
4047
4047
  this.stats = this._getValue(this._options.stats, false);
4048
4048
  this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
@@ -5378,16 +5378,16 @@ var require_settings4 = __commonJS({
5378
5378
  "use strict";
5379
5379
  Object.defineProperty(exports2, "__esModule", { value: true });
5380
5380
  exports2.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
5381
- var fs3 = require("fs");
5381
+ var fs4 = require("fs");
5382
5382
  var os2 = require("os");
5383
5383
  var CPU_COUNT = Math.max(os2.cpus().length, 1);
5384
5384
  exports2.DEFAULT_FILE_SYSTEM_ADAPTER = {
5385
- lstat: fs3.lstat,
5386
- lstatSync: fs3.lstatSync,
5387
- stat: fs3.stat,
5388
- statSync: fs3.statSync,
5389
- readdir: fs3.readdir,
5390
- readdirSync: fs3.readdirSync
5385
+ lstat: fs4.lstat,
5386
+ lstatSync: fs4.lstatSync,
5387
+ stat: fs4.stat,
5388
+ statSync: fs4.statSync,
5389
+ readdir: fs4.readdir,
5390
+ readdirSync: fs4.readdirSync
5391
5391
  };
5392
5392
  var Settings = class {
5393
5393
  constructor(_options = {}) {
@@ -21593,7 +21593,7 @@ module.exports = __toCommonJS(webpack_exports);
21593
21593
  var import_unplugin2 = require("unplugin");
21594
21594
 
21595
21595
  // src/index.ts
21596
- var import_node_fs3 = require("fs");
21596
+ var import_node_fs4 = require("fs");
21597
21597
  var import_node_process4 = __toESM(require("process"), 1);
21598
21598
  var import_unplugin = require("unplugin");
21599
21599
 
@@ -30350,7 +30350,7 @@ async function loadFile(filename, options = {}) {
30350
30350
  var import_utils = require("@antfu/utils");
30351
30351
  async function generateScript(options, mode) {
30352
30352
  const { dir, fileName, globalName, serve, build } = options.env;
30353
- const folder = await findFolder(import_node_process.default.cwd(), dir || "");
30353
+ const folder = await findFolder(import_node_process.default.cwd(), dir);
30354
30354
  const files = await (0, import_fast_glob.default)("*.+(js|ts)", {
30355
30355
  absolute: true,
30356
30356
  cwd: folder
@@ -30359,7 +30359,7 @@ async function generateScript(options, mode) {
30359
30359
  let target = {};
30360
30360
  const source = [];
30361
30361
  let code = "";
30362
- const name = fileName || "";
30362
+ const name = fileName;
30363
30363
  for (const file of files) {
30364
30364
  try {
30365
30365
  const mod = await loadFile(file);
@@ -30419,7 +30419,7 @@ async function findFolder(directoryPath, dir) {
30419
30419
 
30420
30420
  // src/core/options.ts
30421
30421
  var import_utils2 = require("@antfu/utils");
30422
- async function resolveOptions(options) {
30422
+ function resolveOptions(options) {
30423
30423
  const defaults2 = {
30424
30424
  env: {
30425
30425
  dir: "config",
@@ -30427,6 +30427,10 @@ async function resolveOptions(options) {
30427
30427
  globalName: "manifest",
30428
30428
  serve: /dev|development/i,
30429
30429
  build: /prod|production/i
30430
+ },
30431
+ compress: {
30432
+ outDir: "dist",
30433
+ ignoreBase: true
30430
30434
  }
30431
30435
  };
30432
30436
  const mergeOptions = (0, import_utils2.deepMerge)(defaults2, options);
@@ -30437,8 +30441,9 @@ async function resolveOptions(options) {
30437
30441
  }
30438
30442
 
30439
30443
  // src/core/compress.ts
30444
+ var import_node_fs3 = __toESM(require("fs"), 1);
30440
30445
  var import_node_process3 = __toESM(require("process"), 1);
30441
- var compressing = __toESM(require("compressing"), 1);
30446
+ var import_archiver = __toESM(require("archiver"), 1);
30442
30447
 
30443
30448
  // node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js
30444
30449
  var ANSI_BACKGROUND_OFFSET = 10;
@@ -30945,10 +30950,19 @@ var Log = class {
30945
30950
 
30946
30951
  // src/core/compress.ts
30947
30952
  async function createCompress(options) {
30948
- Log.log("Compressing the directory", options);
30953
+ const { outDir, ignoreBase } = options;
30954
+ const zipFilePath = `${outDir}.zip`;
30955
+ Log.log("Compressing the directory", outDir);
30949
30956
  try {
30950
- await compressing.zip.compressDir("./dist", "./dist.zip");
30951
- Log.success("Successfully compressed the directory", options);
30957
+ const output = import_node_fs3.default.createWriteStream(zipFilePath);
30958
+ const archive = (0, import_archiver.default)("zip", {
30959
+ zlib: { level: 9 }
30960
+ // 设置压缩级别为最高
30961
+ });
30962
+ archive.pipe(output);
30963
+ archive.directory(outDir, ignoreBase ? outDir : false);
30964
+ await archive.finalize();
30965
+ Log.success("Successfully compressed the directory", outDir);
30952
30966
  import_node_process3.default.exit(0);
30953
30967
  } catch (error) {
30954
30968
  Log.error("Error compressing the directory", error);
@@ -30971,8 +30985,7 @@ var unpluginFactory = (options = {}) => {
30971
30985
  },
30972
30986
  async load(id) {
30973
30987
  if (id.startsWith(resolvedVirtualEnvId)) {
30974
- const config = await resolved;
30975
- const { code, watchFiles } = await generateScript(config, "serve");
30988
+ const { code, watchFiles } = await generateScript(resolved, "serve");
30976
30989
  watchFiles.forEach((file) => {
30977
30990
  this.addWatchFile(file);
30978
30991
  });
@@ -30988,14 +31001,13 @@ var unpluginFactory = (options = {}) => {
30988
31001
  return resolvedVirtualEnvId;
30989
31002
  },
30990
31003
  async load(id) {
30991
- const config = await resolved;
30992
- const { emit, script } = await generateScript(config, "build");
31004
+ const { emit, script } = await generateScript(resolved, "build");
30993
31005
  if (id.startsWith(resolvedVirtualEnvId)) {
30994
31006
  this.emitFile(emit);
30995
31007
  return "";
30996
31008
  }
30997
31009
  if (id.endsWith(".html")) {
30998
- let code = await import_node_fs3.promises.readFile(id, "utf8");
31010
+ let code = await import_node_fs4.promises.readFile(id, "utf8");
30999
31011
  code = code.replace(/<\/head>/gm, script);
31000
31012
  return {
31001
31013
  code
@@ -31005,7 +31017,8 @@ var unpluginFactory = (options = {}) => {
31005
31017
  },
31006
31018
  buildEnd: () => {
31007
31019
  import_node_process4.default.on("beforeExit", async () => {
31008
- await createCompress({});
31020
+ const { compress } = resolved;
31021
+ await createCompress(compress);
31009
31022
  });
31010
31023
  }
31011
31024
  }];
package/dist/webpack.js CHANGED
@@ -5,8 +5,8 @@
5
5
 
6
6
  import {
7
7
  webpack_default
8
- } from "./chunk-R5LAC3HA.js";
9
- import "./chunk-EQCBPN6Z.js";
8
+ } from "./chunk-5EP4GEYR.js";
9
+ import "./chunk-2KZLPXSE.js";
10
10
  export {
11
11
  webpack_default as default
12
12
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unplugin-env",
3
3
  "type": "module",
4
- "version": "0.1.4",
4
+ "version": "0.1.5",
5
5
  "packageManager": "pnpm@7.1.1",
6
6
  "description": "Register global imports on demand for Vite and Webpack",
7
7
  "license": "MIT",
@@ -111,7 +111,7 @@
111
111
  },
112
112
  "dependencies": {
113
113
  "@antfu/utils": "^0.7.7",
114
- "compressing": "^1.10.0",
114
+ "archiver": "^7.0.1",
115
115
  "local-pkg": "^0.5.0",
116
116
  "unplugin": "^1.10.1"
117
117
  },
@@ -119,6 +119,7 @@
119
119
  "@antfu/eslint-config": "^2.13.2",
120
120
  "@nuxt/kit": "^3.11.2",
121
121
  "@nuxt/schema": "^3.11.2",
122
+ "@types/archiver": "^6.0.2",
122
123
  "@types/node": "^20.12.7",
123
124
  "bumpp": "^9.4.0",
124
125
  "chalk": "^5.3.0",