@michijs/dev-server 0.7.12 → 0.7.14
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/bin/config/config.js
CHANGED
|
@@ -3,32 +3,17 @@ import coloredString from "../utils/coloredString.js";
|
|
|
3
3
|
import { copy } from "../utils/copy.js";
|
|
4
4
|
import { getPath } from "../utils/getPath.js";
|
|
5
5
|
import { userConfig } from "./userConfig.js";
|
|
6
|
-
import {
|
|
6
|
+
import { resolve } from "path";
|
|
7
7
|
import { jsAndTsRegex, jsonTransformer, notJsAndTsRegex, transformers, } from "../actions/start/transformers.js";
|
|
8
8
|
import { dirname } from "path";
|
|
9
9
|
import { fileURLToPath } from "url";
|
|
10
10
|
import { counterPlugin } from "./plugins/counter.js";
|
|
11
|
+
import { getCurrentCommitSha } from "../utils/getCurrentCommitSha.js";
|
|
11
12
|
const minify = process.env.NODE_ENV === "PRODUCTION";
|
|
12
13
|
const devServerListener = process.env.NODE_ENV === "DEVELOPMENT"
|
|
13
14
|
? [getPath(`${dirname(fileURLToPath(import.meta.url))}/public/client.js`)]
|
|
14
15
|
: [];
|
|
15
16
|
export const connections = [];
|
|
16
|
-
const getCurrentCommitSha = () => {
|
|
17
|
-
try {
|
|
18
|
-
const headPath = join(".git", "HEAD");
|
|
19
|
-
const headContent = fs.readFileSync(headPath, "utf-8").trim();
|
|
20
|
-
if (headContent.startsWith("ref:")) {
|
|
21
|
-
const refPath = join(".git", headContent.split(" ")[1]);
|
|
22
|
-
return fs.readFileSync(refPath, "utf-8").trim();
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
return headContent;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
return "";
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
17
|
const commitSha = getCurrentCommitSha();
|
|
33
18
|
const defaultEntryPoint = fs.existsSync("src/index.tsx")
|
|
34
19
|
? "src/index.tsx"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getCurrentCommitSha: () => string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
export const getCurrentCommitSha = () => {
|
|
4
|
+
try {
|
|
5
|
+
const headPath = join(".git", "HEAD");
|
|
6
|
+
const headContent = fs.readFileSync(headPath, "utf-8").trim();
|
|
7
|
+
if (headContent.startsWith("ref:")) {
|
|
8
|
+
const refPath = join(".git", headContent.split(" ")[1]);
|
|
9
|
+
return fs.readFileSync(refPath, "utf-8").trim();
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
return headContent;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return "";
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { config } from "../config/config.js";
|
|
2
2
|
import { getAllFiles } from "./getAllFiles.js";
|
|
3
3
|
import { transformSync as esbuild } from "esbuild";
|
|
4
|
+
import { getCurrentCommitSha } from "./getCurrentCommitSha.js";
|
|
5
|
+
const commitSha = getCurrentCommitSha();
|
|
4
6
|
export const serviceWorkerTransformer = (serviceWorkerCode) => {
|
|
5
7
|
const { sourcemap, keepNames, format, outdir, define, target } = config.esbuildOptions;
|
|
6
8
|
try {
|
|
@@ -9,7 +11,9 @@ export const serviceWorkerTransformer = (serviceWorkerCode) => {
|
|
|
9
11
|
define: {
|
|
10
12
|
"michiProcess.env.BUILD_FILES": `${JSON.stringify(allFiles)}`,
|
|
11
13
|
// Time at GMT+0
|
|
12
|
-
"michiProcess.env.CACHE_NAME":
|
|
14
|
+
"michiProcess.env.CACHE_NAME": commitSha !== ""
|
|
15
|
+
? `"${commitSha}"`
|
|
16
|
+
: `"${new Date(new Date().toLocaleString("en-US", { timeZone: "Etc/GMT" })).getTime()}"`,
|
|
13
17
|
...define,
|
|
14
18
|
},
|
|
15
19
|
loader: "ts",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@michijs/dev-server",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.14",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/michijs/dev-server.git"
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@michijs/tsconfig": "0.0.4",
|
|
33
|
-
"@types/node": "22.4
|
|
33
|
+
"@types/node": "22.5.4",
|
|
34
34
|
"@types/yargs": "17.0.33",
|
|
35
|
-
"typescript": "5.
|
|
35
|
+
"typescript": "5.6.2"
|
|
36
36
|
},
|
|
37
37
|
"keywords": [
|
|
38
38
|
"react",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"esbuild": "0.23.1",
|
|
59
59
|
"node-watch": "0.7.4",
|
|
60
60
|
"open": "10.1.0",
|
|
61
|
-
"playwright-core": "1.
|
|
61
|
+
"playwright-core": "1.47.0",
|
|
62
62
|
"sharp": "0.33.5",
|
|
63
63
|
"yargs": "17.7.2"
|
|
64
64
|
}
|