@michijs/dev-server 0.7.2 → 0.7.4

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.
@@ -39,7 +39,15 @@ export async function dist(callback, watchOption = false) {
39
39
  tsconfig.include.forEach((x) => copy(x, outDir, transformers, omit));
40
40
  exec(
41
41
  // outDir takes the dir from the extended tsconfig...
42
- `tsc ${watchOption ? "-w --incremental" : ""} --emitDeclarationOnly --project ${config.esbuildOptions.tsconfig} --outDir ${outDir}`, callback);
42
+ `tsc ${watchOption ? "-w --incremental" : ""} --emitDeclarationOnly --project ${config.esbuildOptions.tsconfig} --outDir ${outDir}`, { maxBuffer: 1024 * 500 }, (error, stdout, stderr) => {
43
+ if (stdout)
44
+ console.log(stdout);
45
+ if (error || stderr) {
46
+ console.error(error?.message ?? stderr);
47
+ process.exit(1);
48
+ }
49
+ callback();
50
+ });
43
51
  coloredString(` Dist finished in ${timer.endTimer()}ms`);
44
52
  if (watchOption)
45
53
  tsconfig.include.forEach((x) => {
@@ -1,5 +1,13 @@
1
1
  import { config } from "../config/config.js";
2
2
  import { exec } from "child_process";
3
3
  export async function testTsc(callback) {
4
- exec(`tsc --noEmit --project ${config.esbuildOptions.tsconfig}`, callback);
4
+ exec(`tsc --noEmit --project ${config.esbuildOptions.tsconfig}`, { maxBuffer: 1024 * 500 }, (error, stdout, stderr) => {
5
+ if (stdout)
6
+ console.log(stdout);
7
+ if (error || stderr) {
8
+ console.error(error?.message ?? stderr);
9
+ process.exit(1);
10
+ }
11
+ callback();
12
+ });
5
13
  }
package/bin/cli.js CHANGED
@@ -2,8 +2,15 @@ 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();
12
+ console.log(`
13
+ ${coloredString(`Ready in ${timer.endTimer()}ms.`)}`);
7
14
  const showReadyMessage = () => console.log(`
8
15
  ${coloredString(`Ready in ${timer.endTimer()}ms.`)}`);
9
16
  timer.startTimer();
@@ -49,7 +56,11 @@ export async function cli() {
49
56
  process.env.NODE_ENV =
50
57
  process.env.NODE_ENV ||
51
58
  args.env ||
52
- (args.build || args.minifyAsset ? "PRODUCTION" : args.dist || args.testTsc ? "DISTRIBUTION" : "DEVELOPMENT");
59
+ (args.build || args.minifyAsset
60
+ ? "PRODUCTION"
61
+ : args.dist || args.testTsc
62
+ ? "DISTRIBUTION"
63
+ : "DEVELOPMENT");
53
64
  const generateAssets = args.generateAssets === "" ? "public/assets/icon.svg" : args.generateAssets;
54
65
  if (generateAssets) {
55
66
  const action = await import("./actions/generateAssets.js");
@@ -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
- dependencies.concat(devDependencies).forEach((packagePath) => {
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
@@ -180,6 +180,7 @@ export interface MichiProcessType {
180
180
  env: {
181
181
  BUILD_FILES: string[];
182
182
  CACHE_NAME: string;
183
+ COMMIT_SHA: string;
183
184
  NODE_ENV: DefaultEnvironment;
184
185
  };
185
186
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@michijs/dev-server",
3
3
  "license": "MIT",
4
- "version": "0.7.2",
4
+ "version": "0.7.4",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/michijs/dev-server.git"
@@ -29,9 +29,9 @@
29
29
  "link": "bunx concurrently bun:dist-w bun:bun-link"
30
30
  },
31
31
  "devDependencies": {
32
- "@michijs/tsconfig": "0.0.3",
32
+ "@michijs/tsconfig": "0.0.4",
33
33
  "typescript": "^5.5.3",
34
- "@types/node": "22.0.0",
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.14.0",
60
+ "puppeteer": "22.15.0",
61
61
  "sharp": "0.33.4",
62
62
  "yargs": "17.7.2"
63
63
  }