@forsakringskassan/vite-lib-config 4.3.6 → 4.4.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.
@@ -3,6 +3,8 @@
3
3
  const { run } = require("../dist/api-extractor");
4
4
 
5
5
  const argv = process.argv.slice(2);
6
+
7
+ /* eslint-disable-next-line unicorn/prefer-top-level-await -- technical debt, this still runs as commonjs */
6
8
  run(argv).catch((err) => {
7
9
  console.error(err);
8
10
  process.exitCode = 1;
@@ -3,6 +3,8 @@
3
3
  import { cli } from "../dist/cli.mjs";
4
4
 
5
5
  const argv = process.argv.slice(2);
6
+
7
+ /* eslint-disable-next-line unicorn/prefer-top-level-await -- technical debt, this still runs as commonjs */
6
8
  cli(argv).catch((err) => {
7
9
  console.error(err);
8
10
  process.exitCode = 1;
@@ -39,6 +39,11 @@ var require_vendors = __commonJS({
39
39
  env: "AGOLA_GIT_REF",
40
40
  pr: "AGOLA_PULL_REQUEST_ID"
41
41
  },
42
+ {
43
+ name: "Alpic",
44
+ constant: "ALPIC",
45
+ env: "ALPIC_HOST"
46
+ },
42
47
  {
43
48
  name: "Appcircle",
44
49
  constant: "APPCIRCLE",
@@ -119,6 +124,16 @@ var require_vendors = __commonJS({
119
124
  env: "CIRRUS_CI",
120
125
  pr: "CIRRUS_PR"
121
126
  },
127
+ {
128
+ name: "Cloudflare Pages",
129
+ constant: "CLOUDFLARE_PAGES",
130
+ env: "CF_PAGES"
131
+ },
132
+ {
133
+ name: "Cloudflare Workers",
134
+ constant: "CLOUDFLARE_WORKERS",
135
+ env: "WORKERS_CI"
136
+ },
122
137
  {
123
138
  name: "Codefresh",
124
139
  constant: "CODEFRESH",
@@ -397,23 +412,25 @@ var require_ci_info = __commonJS({
397
412
  exports2.name = null;
398
413
  exports2.isPR = null;
399
414
  exports2.id = null;
400
- vendors.forEach(function(vendor) {
401
- const envs = Array.isArray(vendor.env) ? vendor.env : [vendor.env];
402
- const isCI2 = envs.every(function(obj) {
403
- return checkEnv(obj);
415
+ if (env.CI !== "false") {
416
+ vendors.forEach(function(vendor) {
417
+ const envs = Array.isArray(vendor.env) ? vendor.env : [vendor.env];
418
+ const isCI2 = envs.every(function(obj) {
419
+ return checkEnv(obj);
420
+ });
421
+ exports2[vendor.constant] = isCI2;
422
+ if (!isCI2) {
423
+ return;
424
+ }
425
+ exports2.name = vendor.name;
426
+ exports2.isPR = checkPR(vendor);
427
+ exports2.id = vendor.constant;
404
428
  });
405
- exports2[vendor.constant] = isCI2;
406
- if (!isCI2) {
407
- return;
408
- }
409
- exports2.name = vendor.name;
410
- exports2.isPR = checkPR(vendor);
411
- exports2.id = vendor.constant;
412
- });
429
+ }
413
430
  exports2.isCI = !!(env.CI !== "false" && // Bypass all checks if CI env is explicitly set to 'false'
414
431
  (env.BUILD_ID || // Jenkins, Cloudbees
415
432
  env.BUILD_NUMBER || // Jenkins, TeamCity
416
- env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari
433
+ env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari, Cloudflare Pages/Workers
417
434
  env.CI_APP_ID || // Appflow
418
435
  env.CI_BUILD_ID || // Appflow
419
436
  env.CI_BUILD_NUMBER || // Appflow
@@ -2453,8 +2470,17 @@ var Queue = class {
2453
2470
  }
2454
2471
  this.#head = this.#head.next;
2455
2472
  this.#size--;
2473
+ if (!this.#head) {
2474
+ this.#tail = void 0;
2475
+ }
2456
2476
  return current.value;
2457
2477
  }
2478
+ peek() {
2479
+ if (!this.#head) {
2480
+ return;
2481
+ }
2482
+ return this.#head.value;
2483
+ }
2458
2484
  clear() {
2459
2485
  this.#head = void 0;
2460
2486
  this.#tail = void 0;
@@ -2470,6 +2496,11 @@ var Queue = class {
2470
2496
  current = current.next;
2471
2497
  }
2472
2498
  }
2499
+ *drain() {
2500
+ while (this.#head) {
2501
+ yield this.dequeue();
2502
+ }
2503
+ }
2473
2504
  };
2474
2505
 
2475
2506
  // node_modules/p-locate/node_modules/p-limit/index.js
@@ -5718,7 +5749,7 @@ function createDedent(options) {
5718
5749
  result = result.trim();
5719
5750
  }
5720
5751
  if (escapeSpecialCharacters) {
5721
- result = result.replace(/\\n/g, "\n");
5752
+ result = result.replace(/\\n/g, "\n").replace(/\\t/g, " ").replace(/\\r/g, "\r").replace(/\\v/g, "\v").replace(/\\b/g, "\b").replace(/\\f/g, "\f").replace(/\\0/g, "\0").replace(/\\x([\da-fA-F]{2})/g, (_2, h) => String.fromCharCode(parseInt(h, 16))).replace(/\\u\{([\da-fA-F]{1,6})\}/g, (_2, h) => String.fromCodePoint(parseInt(h, 16))).replace(/\\u([\da-fA-F]{4})/g, (_2, h) => String.fromCharCode(parseInt(h, 16)));
5722
5753
  }
5723
5754
  if (typeof Bun !== "undefined") {
5724
5755
  result = result.replace(
@@ -5756,7 +5787,7 @@ function extractAugmentations(content) {
5756
5787
  return Array.from(matches).map((it2) => {
5757
5788
  const [withDeclaration, name = "", withoutDeclaration] = it2;
5758
5789
  if (name.startsWith(".")) {
5759
- const exported = withoutDeclaration.replace(
5790
+ const exported = withoutDeclaration.replaceAll(
5760
5791
  /^(\s*)interface/g,
5761
5792
  "$1export interface"
5762
5793
  );
@@ -5770,7 +5801,7 @@ function extractAugmentations(content) {
5770
5801
  // src/api-extractor.ts
5771
5802
  async function getConfigFiles(configFiles) {
5772
5803
  if (configFiles.length > 0) {
5773
- return configFiles.map((it2) => ts(it2)).flat();
5804
+ return configFiles.flatMap((it2) => ts(it2));
5774
5805
  } else {
5775
5806
  const result = await findUp("api-extractor.json");
5776
5807
  return result ? [result] : [];
@@ -5781,7 +5812,7 @@ async function findReferencedFiles(filename, visited) {
5781
5812
  return;
5782
5813
  }
5783
5814
  visited.add(filename);
5784
- const content = await import_promises2.default.readFile(filename, "utf-8");
5815
+ const content = await import_promises2.default.readFile(filename, "utf8");
5785
5816
  const matches = content.matchAll(/^(?:import|export)[^"]*"([^"]+)";?$/gm);
5786
5817
  for (const match of Array.from(matches)) {
5787
5818
  const modname = match[1];
@@ -5810,13 +5841,13 @@ async function patchAugmentations(config) {
5810
5841
  return;
5811
5842
  }
5812
5843
  async function extract(filename) {
5813
- const content = await import_promises2.default.readFile(filename, "utf-8");
5844
+ const content = await import_promises2.default.readFile(filename, "utf8");
5814
5845
  return extractAugmentations(content);
5815
5846
  }
5816
5847
  async function patch(filename, augmentations2) {
5817
- const content = await import_promises2.default.readFile(filename, "utf-8");
5848
+ const content = await import_promises2.default.readFile(filename, "utf8");
5818
5849
  const patched = [content, ...augmentations2].join("\n\n");
5819
- await import_promises2.default.writeFile(filename, patched, "utf-8");
5850
+ await import_promises2.default.writeFile(filename, patched, "utf8");
5820
5851
  }
5821
5852
  console.log();
5822
5853
  console.group("Patching module augmentations");
@@ -5848,13 +5879,13 @@ async function patchDeclareVarVls(declarationDir) {
5848
5879
  const filenames = await Ze("**/*.vue.d.ts", { cwd: declarationDir });
5849
5880
  const promises = filenames.map(async (filename) => {
5850
5881
  const filePath = import_node_path4.default.join(declarationDir, filename);
5851
- const content = await import_promises2.default.readFile(filePath, "utf-8");
5882
+ const content = await import_promises2.default.readFile(filePath, "utf8");
5852
5883
  const updated = content.replace(
5853
5884
  /declare var (__VLS_\d+)/,
5854
5885
  "declare const $1"
5855
5886
  );
5856
5887
  if (content !== updated) {
5857
- await import_promises2.default.writeFile(filePath, updated, "utf-8");
5888
+ await import_promises2.default.writeFile(filePath, updated, "utf8");
5858
5889
  numPatchedFiles++;
5859
5890
  console.log(filename);
5860
5891
  }
@@ -5867,9 +5898,9 @@ async function patchDeclareVarVls(declarationDir) {
5867
5898
  );
5868
5899
  }
5869
5900
  async function run(argv) {
5870
- const flags = argv.filter((it2) => it2.startsWith("--"));
5901
+ const flags = new Set(argv.filter((it2) => it2.startsWith("--")));
5871
5902
  const positional = argv.filter((it2) => !it2.startsWith("--"));
5872
- if (flags.includes("--help")) {
5903
+ if (flags.has("--help")) {
5873
5904
  console.log("usage: fk-api-extractor [OPTIONS..] [FILENAME..]");
5874
5905
  console.log(`
5875
5906
  --help Show this help.
@@ -5898,7 +5929,7 @@ only.
5898
5929
  }
5899
5930
  console.groupEnd();
5900
5931
  console.log();
5901
- if (flags.includes("--patch-declare-var-vls")) {
5932
+ if (flags.has("--patch-declare-var-vls")) {
5902
5933
  await patchDeclareVarVls("temp/types");
5903
5934
  }
5904
5935
  for (const filePath of configFiles) {
@@ -5919,7 +5950,7 @@ only.
5919
5950
  );
5920
5951
  process.exitCode = 1;
5921
5952
  }
5922
- if (flags.includes("--patch-augmentations")) {
5953
+ if (flags.has("--patch-augmentations")) {
5923
5954
  await patchAugmentations(config);
5924
5955
  }
5925
5956
  }
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.57.3"
8
+ "packageVersion": "7.57.7"
9
9
  }
10
10
  ]
11
11
  }
@@ -2908,7 +2908,7 @@ var import_node_path = __toESM(require("node:path"), 1);
2908
2908
  var import_node_crypto = __toESM(require("node:crypto"), 1);
2909
2909
  var import_node_tty = require("node:tty");
2910
2910
  var import_node_util = require("node:util");
2911
- var version = "6.0.4";
2911
+ var version = "6.0.5";
2912
2912
  function resolveCompiler(root) {
2913
2913
  const compiler = tryResolveCompiler(root) || tryResolveCompiler();
2914
2914
  if (!compiler) throw new Error("Failed to resolve vue/compiler-sfc.\n@vitejs/plugin-vue requires vue (>=3.2.25) to be present in the dependency tree.");
@@ -7594,19 +7594,17 @@ var folder = {
7594
7594
  function customMappingPlugin() {
7595
7595
  return {
7596
7596
  name: "fk:custom-mapping",
7597
- renderStart(options) {
7598
- const { format } = options;
7597
+ outputOptions(options) {
7598
+ const { format, dir, entryFileNames } = options;
7599
7599
  if (format !== "es" && format !== "cjs") {
7600
7600
  return;
7601
7601
  }
7602
7602
  const replacement = folder[format];
7603
- options.dir = options.dir?.replace("[custom-format]", replacement);
7604
- if (typeof options.entryFileNames === "string") {
7605
- options.entryFileNames = options.entryFileNames.replace(
7606
- "[custom-format]",
7607
- replacement
7608
- );
7609
- }
7603
+ return {
7604
+ ...options,
7605
+ dir: dir?.replace("[custom-format]", replacement),
7606
+ entryFileNames: typeof entryFileNames === "string" ? entryFileNames.replace("[custom-format]", replacement) : entryFileNames
7607
+ };
7610
7608
  }
7611
7609
  };
7612
7610
  }
@@ -7615,7 +7613,7 @@ function customMappingPlugin() {
7615
7613
  var import_promises2 = __toESM(require("node:fs/promises"));
7616
7614
  var import_node_path3 = __toESM(require("node:path"));
7617
7615
 
7618
- // src/utils/lookupFile.ts
7616
+ // src/utils/lookup-file.ts
7619
7617
  var import_node_fs2 = __toESM(require("node:fs"));
7620
7618
  var extensions = ["ts", "mts", "mjs", "js"];
7621
7619
  function lookupFile(nameWithoutExtension) {
@@ -7680,10 +7678,14 @@ function indexHtmlPlugin() {
7680
7678
  transformIndexHtml: {
7681
7679
  order: "pre",
7682
7680
  async handler() {
7683
- const content = await import_promises2.default.readFile(templateFile, "utf-8");
7684
- return content.replace(/{{([^}]+)}}/g, (match, key) => {
7685
- return templateData[key.trim()] ?? match;
7686
- });
7681
+ const content = await import_promises2.default.readFile(templateFile, "utf8");
7682
+ return content.replaceAll(
7683
+ /* eslint-disable-next-line sonarjs/slow-regex -- technical debt */
7684
+ /{{([^}]+)}}/g,
7685
+ (match, key) => {
7686
+ return templateData[key.trim()] ?? match;
7687
+ }
7688
+ );
7687
7689
  }
7688
7690
  },
7689
7691
  config(config) {
@@ -7725,7 +7727,7 @@ function packageJsonPlugin() {
7725
7727
  // src/utils/read-json-file.ts
7726
7728
  var import_node_fs3 = __toESM(require("node:fs"));
7727
7729
  function readJsonFile(filename) {
7728
- return JSON.parse(import_node_fs3.default.readFileSync(filename, "utf-8"));
7730
+ return JSON.parse(import_node_fs3.default.readFileSync(filename, "utf8"));
7729
7731
  }
7730
7732
 
7731
7733
  // src/utils/detect-vue-major.ts
@@ -7830,7 +7832,7 @@ function createDedent(options) {
7830
7832
  result = result.trim();
7831
7833
  }
7832
7834
  if (escapeSpecialCharacters) {
7833
- result = result.replace(/\\n/g, "\n");
7835
+ result = result.replace(/\\n/g, "\n").replace(/\\t/g, " ").replace(/\\r/g, "\r").replace(/\\v/g, "\v").replace(/\\b/g, "\b").replace(/\\f/g, "\f").replace(/\\0/g, "\0").replace(/\\x([\da-fA-F]{2})/g, (_2, h) => String.fromCharCode(parseInt(h, 16))).replace(/\\u\{([\da-fA-F]{1,6})\}/g, (_2, h) => String.fromCodePoint(parseInt(h, 16))).replace(/\\u([\da-fA-F]{4})/g, (_2, h) => String.fromCharCode(parseInt(h, 16)));
7834
7836
  }
7835
7837
  if (typeof Bun !== "undefined") {
7836
7838
  result = result.replace(
@@ -7944,7 +7946,9 @@ var packageJson = readJsonFile("package.json");
7944
7946
  var dependencies = Object.keys(packageJson.dependencies ?? {});
7945
7947
  var peerDependencies = Object.keys(packageJson.peerDependencies ?? {});
7946
7948
  var externalDependencies = packageJson.externalDependencies;
7947
- var allDependencies = [...dependencies, ...peerDependencies].sort();
7949
+ var allDependencies = [...dependencies, ...peerDependencies].toSorted(
7950
+ (a, b) => a.localeCompare(b)
7951
+ );
7948
7952
  var external = /* @__PURE__ */ new Set([
7949
7953
  ...externalDependencies ?? dependencies,
7950
7954
  ...peerDependencies
@@ -8016,7 +8020,8 @@ async function defineConfig(config = {}) {
8016
8020
  result = defaultConfig;
8017
8021
  }
8018
8022
  const { build } = result;
8019
- const external2 = build?.rollupOptions?.external;
8023
+ const external2 = build?.rolldownOptions?.external ?? /* eslint-disable-next-line @typescript-eslint/no-deprecated -- for backwards compatibility */
8024
+ build?.rollupOptions?.external ?? [];
8020
8025
  console.group(import_picocolors.default.bold("Configuration:"));
8021
8026
  console.log(
8022
8027
  "Internal dependencies:",
@@ -2898,7 +2898,7 @@ import path from "node:path";
2898
2898
  import crypto from "node:crypto";
2899
2899
  import { isatty } from "node:tty";
2900
2900
  import { formatWithOptions, inspect } from "node:util";
2901
- var version = "6.0.4";
2901
+ var version = "6.0.5";
2902
2902
  function resolveCompiler(root) {
2903
2903
  const compiler = tryResolveCompiler(root) || tryResolveCompiler();
2904
2904
  if (!compiler) throw new Error("Failed to resolve vue/compiler-sfc.\n@vitejs/plugin-vue requires vue (>=3.2.25) to be present in the dependency tree.");
@@ -7584,19 +7584,17 @@ var folder = {
7584
7584
  function customMappingPlugin() {
7585
7585
  return {
7586
7586
  name: "fk:custom-mapping",
7587
- renderStart(options) {
7588
- const { format } = options;
7587
+ outputOptions(options) {
7588
+ const { format, dir, entryFileNames } = options;
7589
7589
  if (format !== "es" && format !== "cjs") {
7590
7590
  return;
7591
7591
  }
7592
7592
  const replacement = folder[format];
7593
- options.dir = options.dir?.replace("[custom-format]", replacement);
7594
- if (typeof options.entryFileNames === "string") {
7595
- options.entryFileNames = options.entryFileNames.replace(
7596
- "[custom-format]",
7597
- replacement
7598
- );
7599
- }
7593
+ return {
7594
+ ...options,
7595
+ dir: dir?.replace("[custom-format]", replacement),
7596
+ entryFileNames: typeof entryFileNames === "string" ? entryFileNames.replace("[custom-format]", replacement) : entryFileNames
7597
+ };
7600
7598
  }
7601
7599
  };
7602
7600
  }
@@ -7605,7 +7603,7 @@ function customMappingPlugin() {
7605
7603
  import fs4 from "node:fs/promises";
7606
7604
  import path2 from "node:path";
7607
7605
 
7608
- // src/utils/lookupFile.ts
7606
+ // src/utils/lookup-file.ts
7609
7607
  import fs3 from "node:fs";
7610
7608
  var extensions = ["ts", "mts", "mjs", "js"];
7611
7609
  function lookupFile(nameWithoutExtension) {
@@ -7670,10 +7668,14 @@ function indexHtmlPlugin() {
7670
7668
  transformIndexHtml: {
7671
7669
  order: "pre",
7672
7670
  async handler() {
7673
- const content = await fs4.readFile(templateFile, "utf-8");
7674
- return content.replace(/{{([^}]+)}}/g, (match, key) => {
7675
- return templateData[key.trim()] ?? match;
7676
- });
7671
+ const content = await fs4.readFile(templateFile, "utf8");
7672
+ return content.replaceAll(
7673
+ /* eslint-disable-next-line sonarjs/slow-regex -- technical debt */
7674
+ /{{([^}]+)}}/g,
7675
+ (match, key) => {
7676
+ return templateData[key.trim()] ?? match;
7677
+ }
7678
+ );
7677
7679
  }
7678
7680
  },
7679
7681
  config(config) {
@@ -7715,7 +7717,7 @@ function packageJsonPlugin() {
7715
7717
  // src/utils/read-json-file.ts
7716
7718
  import fs5 from "node:fs";
7717
7719
  function readJsonFile(filename) {
7718
- return JSON.parse(fs5.readFileSync(filename, "utf-8"));
7720
+ return JSON.parse(fs5.readFileSync(filename, "utf8"));
7719
7721
  }
7720
7722
 
7721
7723
  // src/utils/detect-vue-major.ts
@@ -7820,7 +7822,7 @@ function createDedent(options) {
7820
7822
  result = result.trim();
7821
7823
  }
7822
7824
  if (escapeSpecialCharacters) {
7823
- result = result.replace(/\\n/g, "\n");
7825
+ result = result.replace(/\\n/g, "\n").replace(/\\t/g, " ").replace(/\\r/g, "\r").replace(/\\v/g, "\v").replace(/\\b/g, "\b").replace(/\\f/g, "\f").replace(/\\0/g, "\0").replace(/\\x([\da-fA-F]{2})/g, (_2, h) => String.fromCharCode(parseInt(h, 16))).replace(/\\u\{([\da-fA-F]{1,6})\}/g, (_2, h) => String.fromCodePoint(parseInt(h, 16))).replace(/\\u([\da-fA-F]{4})/g, (_2, h) => String.fromCharCode(parseInt(h, 16)));
7824
7826
  }
7825
7827
  if (typeof Bun !== "undefined") {
7826
7828
  result = result.replace(
@@ -7936,7 +7938,9 @@ var packageJson = readJsonFile("package.json");
7936
7938
  var dependencies = Object.keys(packageJson.dependencies ?? {});
7937
7939
  var peerDependencies = Object.keys(packageJson.peerDependencies ?? {});
7938
7940
  var externalDependencies = packageJson.externalDependencies;
7939
- var allDependencies = [...dependencies, ...peerDependencies].sort();
7941
+ var allDependencies = [...dependencies, ...peerDependencies].toSorted(
7942
+ (a, b) => a.localeCompare(b)
7943
+ );
7940
7944
  var external = /* @__PURE__ */ new Set([
7941
7945
  ...externalDependencies ?? dependencies,
7942
7946
  ...peerDependencies
@@ -8008,7 +8012,8 @@ async function defineConfig(config = {}) {
8008
8012
  result = defaultConfig;
8009
8013
  }
8010
8014
  const { build } = result;
8011
- const external2 = build?.rollupOptions?.external;
8015
+ const external2 = build?.rolldownOptions?.external ?? /* eslint-disable-next-line @typescript-eslint/no-deprecated -- for backwards compatibility */
8016
+ build?.rollupOptions?.external ?? [];
8012
8017
  console.group(import_picocolors.default.bold("Configuration:"));
8013
8018
  console.log(
8014
8019
  "Internal dependencies:",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsakringskassan/vite-lib-config",
3
- "version": "4.3.6",
3
+ "version": "4.4.0",
4
4
  "description": "Försäkringskassan toolchain to build libraries with Vite",
5
5
  "keywords": [
6
6
  "vite"
@@ -42,7 +42,7 @@
42
42
  "dist"
43
43
  ],
44
44
  "dependencies": {
45
- "@microsoft/api-extractor": "7.57.3",
45
+ "@microsoft/api-extractor": "7.57.7",
46
46
  "@vue/babel-preset-app": "5.0.9"
47
47
  },
48
48
  "peerDependencies": {
@@ -50,7 +50,7 @@
50
50
  "@babel/plugin-transform-nullish-coalescing-operator": "^7.22.0",
51
51
  "@forsakringskassan/apimock-express": "^1.1.0 || ^2.0.0",
52
52
  "typescript": "^5.0.2",
53
- "vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
53
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0",
54
54
  "vue": "^3.0.0"
55
55
  },
56
56
  "engines": {