@michijs/dev-server 0.7.3 → 0.7.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/bin/cli.js +5 -0
- package/bin/config/config.js +19 -2
- package/bin/types.d.ts +1 -0
- package/package.json +3 -3
package/bin/cli.js
CHANGED
|
@@ -2,7 +2,12 @@ import coloredString from "./utils/coloredString.js";
|
|
|
2
2
|
import yargs from "yargs";
|
|
3
3
|
import { Timer } from "./classes/Timer.js";
|
|
4
4
|
import { hideBin } from "yargs/helpers";
|
|
5
|
+
import { readFileSync } from "fs";
|
|
6
|
+
import { dirname, resolve } from "path";
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
8
|
+
const version = JSON.parse(readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), "..", "package.json"), { encoding: "utf-8" })).version;
|
|
5
9
|
export async function cli() {
|
|
10
|
+
console.log(` ${coloredString(`Running dev server version ${version}.`)}`);
|
|
6
11
|
const timer = new Timer();
|
|
7
12
|
const showReadyMessage = () => console.log(`
|
|
8
13
|
${coloredString(`Ready in ${timer.endTimer()}ms.`)}`);
|
package/bin/config/config.js
CHANGED
|
@@ -3,7 +3,7 @@ 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 { resolve } from "path";
|
|
6
|
+
import { join, 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";
|
|
@@ -13,6 +13,18 @@ const devServerListener = process.env.NODE_ENV === "DEVELOPMENT"
|
|
|
13
13
|
? [getPath(`${dirname(fileURLToPath(import.meta.url))}/public/client.js`)]
|
|
14
14
|
: [];
|
|
15
15
|
export const connections = [];
|
|
16
|
+
const getCurrentCommitSha = () => {
|
|
17
|
+
const headPath = join(".git", "HEAD");
|
|
18
|
+
const headContent = fs.readFileSync(headPath, "utf-8").trim();
|
|
19
|
+
if (headContent.startsWith("ref:")) {
|
|
20
|
+
const refPath = join(".git", headContent.split(" ")[1]);
|
|
21
|
+
return fs.readFileSync(refPath, "utf-8").trim();
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return headContent;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const commitSha = getCurrentCommitSha();
|
|
16
28
|
const defaultEntryPoint = fs.existsSync("src/index.tsx")
|
|
17
29
|
? "src/index.tsx"
|
|
18
30
|
: fs.existsSync("src/index.ts")
|
|
@@ -131,6 +143,7 @@ const config = {
|
|
|
131
143
|
michiProcess: JSON.stringify({
|
|
132
144
|
env: {
|
|
133
145
|
NODE_ENV: process.env.NODE_ENV,
|
|
146
|
+
COMMIT_SHA: commitSha,
|
|
134
147
|
...(userConfig.env ?? {}),
|
|
135
148
|
},
|
|
136
149
|
}),
|
|
@@ -153,7 +166,11 @@ if (config.showLinkedPackages) {
|
|
|
153
166
|
const packageJson = JSON.parse(fs.readFileSync("package.json", "utf8"));
|
|
154
167
|
const dependencies = Object.keys(packageJson.dependencies || {});
|
|
155
168
|
const devDependencies = Object.keys(packageJson.devDependencies || {});
|
|
156
|
-
|
|
169
|
+
const peerDependencies = Object.keys(packageJson.peerDependencies || {});
|
|
170
|
+
dependencies
|
|
171
|
+
.concat(devDependencies)
|
|
172
|
+
.concat(peerDependencies)
|
|
173
|
+
.forEach((packagePath) => {
|
|
157
174
|
const packagePathOnNodeModules = getPath(`node_modules/${packagePath}`);
|
|
158
175
|
if (fs.lstatSync(packagePathOnNodeModules).isSymbolicLink()) {
|
|
159
176
|
const pathToWatch = findSymbolickLinkRealPath(packagePathOnNodeModules);
|
package/bin/types.d.ts
CHANGED
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.5",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/michijs/dev-server.git"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@michijs/tsconfig": "0.0.4",
|
|
33
33
|
"typescript": "^5.5.3",
|
|
34
|
-
"@types/node": "22.
|
|
34
|
+
"@types/node": "22.1.0",
|
|
35
35
|
"@types/yargs": "17.0.32"
|
|
36
36
|
},
|
|
37
37
|
"keywords": [
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"esbuild": "0.23.0",
|
|
58
58
|
"node-watch": "0.7.4",
|
|
59
59
|
"open": "10.1.0",
|
|
60
|
-
"puppeteer": "22.
|
|
60
|
+
"puppeteer": "22.15.0",
|
|
61
61
|
"sharp": "0.33.4",
|
|
62
62
|
"yargs": "17.7.2"
|
|
63
63
|
}
|