bc-deeplib 2.4.2 → 3.0.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.
@@ -28,7 +28,16 @@ declare const MOD_VERSION: string;
28
28
  * Used for build identification.
29
29
  * @example "a1b2c3d4"
30
30
  */
31
- declare const VERSION_HASH: string;
31
+ declare const COMMIT_HASH: string;
32
+
33
+ /**
34
+ * The current mod version caption.
35
+ *
36
+ * This value is computed at build time depending on IS_DEVEL.
37
+ * @example
38
+ * IS_DEVEL === true ? "1.0.0 (a1b2c3d4)" : "1.0.0"
39
+ */
40
+ declare const MOD_VERSION_CAPTION: string;
32
41
 
33
42
  /**
34
43
  * Whether the build is a development build.
@@ -1,3 +1,5 @@
1
1
  type Prettify<T> = {
2
2
  [K in keyof T]: T[K];
3
- } & unknown;
3
+ } & unknown;
4
+
5
+ type Thunk<T> = T | (() => T);
package/lib/build.js CHANGED
@@ -106,8 +106,9 @@ async function buildMod({
106
106
  const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
107
107
 
108
108
  const git = simpleGit({ baseDir: process.cwd() });
109
- const LAST_COMMIT_HASH = await git.log({ maxCount: 1 });
110
- const VERSION_HASH = LAST_COMMIT_HASH?.latest?.hash.substring(0, 8);
109
+ const VERSION = packageJson.version;
110
+ const COMMIT_HASH = (await git.log({ maxCount: 1 }))?.latest?.hash.substring(0, 8);
111
+ const VERSION_CAPTION = IS_DEVEL ? `${VERSION} - ${COMMIT_HASH}` : VERSION;
111
112
 
112
113
  /** @type {import('esbuild').BuildOptions} */
113
114
  const buildOptions = {
@@ -122,15 +123,16 @@ async function buildMod({
122
123
  keepNames: true,
123
124
  define: {
124
125
  PUBLIC_URL: JSON.stringify(PUBLIC_URL),
125
- MOD_VERSION: JSON.stringify(packageJson.version),
126
- VERSION_HASH: JSON.stringify(VERSION_HASH),
126
+ MOD_VERSION: JSON.stringify(VERSION),
127
+ COMMIT_HASH: JSON.stringify(COMMIT_HASH),
128
+ MOD_VERSION_CAPTION: JSON.stringify(VERSION_CAPTION),
127
129
  IS_DEVEL: JSON.stringify(IS_DEVEL),
128
130
  IS_DEBUG: JSON.stringify(cliAllowDebug),
129
131
  ...defines
130
132
  },
131
133
  plugins: [progress(), time(), ...plugins],
132
134
  };
133
-
135
+
134
136
  /** @type {NodeJS.Timeout | null} */
135
137
  let buildTimeout = null;
136
138
  const DEBOUNCE_MS = 100; // Adjust as needed
@@ -144,21 +146,21 @@ async function buildMod({
144
146
  const assetsSrc = path.resolve(__dirname, '../dist/public');
145
147
  const assetsDest = path.resolve(process.cwd(), distDirName, publicDirName);
146
148
 
147
- await build(buildOptions);
148
- copyMatchingFiles(assetsSrc, assetsDest);
149
+ try {
150
+ await build(buildOptions);
151
+ copyMatchingFiles(assetsSrc, assetsDest);
149
152
 
150
- for (const script of scripts) {
151
- try {
153
+ for (const script of scripts) {
152
154
  const { stdout } = await execAsync(`node ${script}`);
153
155
  console.log(stdout);
154
- } catch (err) {
155
- console.error(err);
156
156
  }
157
+ } catch (error) {
158
+ console.error(error);
157
159
  }
158
160
  }
159
161
 
160
162
  await runBuild();
161
-
163
+
162
164
  if (isLocal) {
163
165
 
164
166
  if (isWatch) {
@@ -173,7 +175,7 @@ async function buildMod({
173
175
  watcher.on('change', debounceRunBuild);
174
176
  console.info('🔭 Watching for changes...');
175
177
  }
176
-
178
+
177
179
  if (isServe) {
178
180
  try {
179
181
  serveWithCORS(distDirName, port, host);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bc-deeplib",
3
- "version": "2.4.2",
3
+ "version": "3.0.0",
4
4
  "author": "dDeepLb",
5
5
  "description": "Library for easier development of BC mods, which strives to be a framework :D",
6
6
  "license": "MIT",
@@ -33,10 +33,10 @@
33
33
  "npm-dts": "^1.3.13",
34
34
  "sass": "^1.92.1",
35
35
  "typescript": "^5.9.2",
36
- "typescript-eslint": "^8.43.0"
36
+ "typescript-eslint": "^8.43.0",
37
+ "bondage-club-mod-sdk": "^1.2.0"
37
38
  },
38
39
  "dependencies": {
39
- "bondage-club-mod-sdk": "^1.2.0",
40
40
  "serve-static": "^2.2.0",
41
41
  "simple-git": "^3.28.0",
42
42
  "finalhandler": "^2.1.0",
@@ -48,10 +48,13 @@
48
48
  "esbuild-sass-plugin": "^3.3.1"
49
49
  },
50
50
  "scripts": {
51
- "all": "pnpm build && pnpm type-gen && pnpm asset-copy",
52
- "lint": "eslint src/",
51
+ "all": "pnpm type:check && pnpm build && pnpm type:gen && pnpm type:copy && pnpm asset:copy",
52
+ "lint": "eslint",
53
+ "lint:fix": "eslint --fix",
53
54
  "build": "node scripts/build.js",
54
- "type-gen": "node scripts/type_gen.js",
55
- "asset-copy": "node scripts/asset_copy.js"
55
+ "type:check": "tsc --noEmit",
56
+ "type:gen": "npm-dts generate -e ./src/deeplib.ts -o ./dist/deeplib.d.ts -L error",
57
+ "type:copy": "node scripts/type_copy.js",
58
+ "asset:copy": "node scripts/asset_copy.js"
56
59
  }
57
60
  }