@julien-lin/universal-pwa-cli 1.3.18 → 1.3.20

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.
@@ -0,0 +1,88 @@
1
+ // src/utils/environment-detector.ts
2
+ import { existsSync, statSync } from "fs";
3
+ import { join } from "path";
4
+ import { glob } from "glob";
5
+ function detectEnvironment(projectPath, framework) {
6
+ const indicators = [];
7
+ let environment = "local";
8
+ let confidence = "low";
9
+ let suggestedOutputDir = "public";
10
+ const distDir = join(projectPath, "dist");
11
+ const publicDir = join(projectPath, "public");
12
+ const buildDir = join(projectPath, "build");
13
+ if (existsSync(distDir)) {
14
+ try {
15
+ const distFiles = glob.sync("**/*.{js,css,html}", {
16
+ cwd: distDir,
17
+ absolute: false,
18
+ maxDepth: 2
19
+ });
20
+ if (distFiles.length > 0) {
21
+ indicators.push(`dist/ directory exists with ${distFiles.length} built files`);
22
+ const recentFiles = distFiles.filter((file) => {
23
+ try {
24
+ const filePath = join(distDir, file);
25
+ const stats = statSync(filePath);
26
+ const ageInHours = (Date.now() - stats.mtimeMs) / (1e3 * 60 * 60);
27
+ return ageInHours < 24;
28
+ } catch {
29
+ return false;
30
+ }
31
+ });
32
+ if (recentFiles.length > 0) {
33
+ indicators.push(`${recentFiles.length} recent files in dist/ (last 24h)`);
34
+ environment = "production";
35
+ confidence = "high";
36
+ suggestedOutputDir = "dist";
37
+ } else {
38
+ indicators.push("dist/ exists but files are old (may be stale)");
39
+ environment = "production";
40
+ confidence = "medium";
41
+ suggestedOutputDir = "dist";
42
+ }
43
+ } else {
44
+ indicators.push("dist/ directory exists but is empty");
45
+ }
46
+ } catch {
47
+ }
48
+ }
49
+ if (existsSync(buildDir) && environment === "local") {
50
+ try {
51
+ const buildFiles = glob.sync("**/*.{js,css,html}", {
52
+ cwd: buildDir,
53
+ absolute: false,
54
+ maxDepth: 2
55
+ });
56
+ if (buildFiles.length > 0) {
57
+ indicators.push(`build/ directory exists with ${buildFiles.length} built files`);
58
+ environment = "production";
59
+ confidence = "high";
60
+ suggestedOutputDir = "build";
61
+ }
62
+ } catch {
63
+ }
64
+ }
65
+ if ((framework === "React" || framework === "Vite") && existsSync(distDir)) {
66
+ if (environment === "local") {
67
+ environment = "production";
68
+ confidence = "medium";
69
+ suggestedOutputDir = "dist";
70
+ indicators.push("React/Vite project with dist/ directory (likely production)");
71
+ }
72
+ }
73
+ if (environment === "local" && indicators.length === 0) {
74
+ indicators.push("No production build detected, using local mode");
75
+ confidence = "medium";
76
+ suggestedOutputDir = "public";
77
+ }
78
+ return {
79
+ environment,
80
+ confidence,
81
+ indicators,
82
+ suggestedOutputDir
83
+ };
84
+ }
85
+
86
+ export {
87
+ detectEnvironment
88
+ };
@@ -0,0 +1,122 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
12
+ });
13
+ var __commonJS = (cb, mod) => function __require2() {
14
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
32
+
33
+ // src/utils/environment-detector.ts
34
+ import { existsSync, statSync } from "fs";
35
+ import { join } from "path";
36
+ import { glob } from "glob";
37
+ function detectEnvironment(projectPath, framework) {
38
+ const indicators = [];
39
+ let environment = "local";
40
+ let confidence = "low";
41
+ let suggestedOutputDir = "public";
42
+ const distDir = join(projectPath, "dist");
43
+ const buildDir = join(projectPath, "build");
44
+ if (existsSync(distDir)) {
45
+ try {
46
+ const distFiles = glob.sync("**/*.{js,css,html}", {
47
+ cwd: distDir,
48
+ absolute: false,
49
+ maxDepth: 2
50
+ });
51
+ if (distFiles.length > 0) {
52
+ indicators.push(`dist/ directory exists with ${distFiles.length} built files`);
53
+ const recentFiles = distFiles.filter((file) => {
54
+ try {
55
+ const filePath = join(distDir, file);
56
+ const stats = statSync(filePath);
57
+ const ageInHours = (Date.now() - stats.mtimeMs) / (1e3 * 60 * 60);
58
+ return ageInHours < 24;
59
+ } catch {
60
+ return false;
61
+ }
62
+ });
63
+ if (recentFiles.length > 0) {
64
+ indicators.push(`${recentFiles.length} recent files in dist/ (last 24h)`);
65
+ environment = "production";
66
+ confidence = "high";
67
+ suggestedOutputDir = "dist";
68
+ } else {
69
+ indicators.push("dist/ exists but files are old (may be stale)");
70
+ environment = "production";
71
+ confidence = "medium";
72
+ suggestedOutputDir = "dist";
73
+ }
74
+ } else {
75
+ indicators.push("dist/ directory exists but is empty");
76
+ }
77
+ } catch {
78
+ }
79
+ }
80
+ if (existsSync(buildDir) && environment === "local") {
81
+ try {
82
+ const buildFiles = glob.sync("**/*.{js,css,html}", {
83
+ cwd: buildDir,
84
+ absolute: false,
85
+ maxDepth: 2
86
+ });
87
+ if (buildFiles.length > 0) {
88
+ indicators.push(`build/ directory exists with ${buildFiles.length} built files`);
89
+ environment = "production";
90
+ confidence = "high";
91
+ suggestedOutputDir = "build";
92
+ }
93
+ } catch {
94
+ }
95
+ }
96
+ if ((framework === "React" || framework === "Vite") && existsSync(distDir)) {
97
+ if (environment === "local") {
98
+ environment = "production";
99
+ confidence = "medium";
100
+ suggestedOutputDir = "dist";
101
+ indicators.push("React/Vite project with dist/ directory (likely production)");
102
+ }
103
+ }
104
+ if (environment === "local" && indicators.length === 0) {
105
+ indicators.push("No production build detected, using local mode");
106
+ confidence = "medium";
107
+ suggestedOutputDir = "public";
108
+ }
109
+ return {
110
+ environment,
111
+ confidence,
112
+ indicators,
113
+ suggestedOutputDir
114
+ };
115
+ }
116
+
117
+ export {
118
+ __require,
119
+ __commonJS,
120
+ __toESM,
121
+ detectEnvironment
122
+ };
@@ -0,0 +1,6 @@
1
+ import {
2
+ detectEnvironment
3
+ } from "./chunk-XETADPJH.js";
4
+ export {
5
+ detectEnvironment
6
+ };
@@ -0,0 +1,6 @@
1
+ import {
2
+ detectEnvironment
3
+ } from "./chunk-35T5DDFX.js";
4
+ export {
5
+ detectEnvironment
6
+ };