@needle-tools/gltf-build-pipeline 1.6.0-alpha.4 → 1.6.0-alpha.6

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/CHANGELOG.md CHANGED
@@ -4,8 +4,12 @@ All notable changes to this package will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## [1.6.0-alpha.4] - 2023-05-28
7
+ ## [1.6.0-alpha.6] - 2023-05-30
8
+ - fix: npx cli command return wrong error due to `packGLTF` not returning a booelan
9
+
10
+ ## [1.6.0-alpha.5] - 2023-05-28
8
11
  - fix: determine build pipeline version
12
+ - change: throw error and exit process if packing or transform fails
9
13
 
10
14
  ## [1.6.0-alpha.2] - 2023-05-27
11
15
  - add: `gltf-build-pipeline` commandline support with `transform` and `compress` (pack-gltf) options.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/gltf-build-pipeline",
3
- "version": "1.6.0-alpha.4",
3
+ "version": "1.6.0-alpha.6",
4
4
  "description": "Pipeline and tools for optimizing gltf files using gltf-transform and compression settings within glTF extensions",
5
5
  "main": "index.mjs",
6
6
  "type": "module",
@@ -51,7 +51,8 @@
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/node": "^18.7.23",
54
- "npm-watch": "^0.11.0",
54
+ "nodemon": "^3.1.2",
55
+ "npm-watch": "^0.13.0",
55
56
  "typescript": "^4.9.5"
56
57
  },
57
58
  "author": {
@@ -9,6 +9,7 @@ import { cacheSizeLimit, clearCache } from '../cache/cache.js';
9
9
  import { existsSync, statSync } from 'fs';
10
10
  import { foreachGLTF } from '../utils/fileutils.js';
11
11
  import { dirname } from 'path';
12
+ import { ERROR_CODES } from '../constants.js';
12
13
  // For testing / dev you can run `npm link` in the package directory
13
14
  // For removing the link run `npm rm --global @needle-tools/gltf-build-pipeline`
14
15
  program
@@ -77,7 +78,7 @@ Compress a single glTF file. The input file is compressed and written to the out
77
78
  const filename = file.replaceAll("\\", "/").split("/").pop();
78
79
  outputFile = options.output?.toString() + "/" + filename;
79
80
  }
80
- await packGLTF(file, outputFile, {
81
+ const res = await packGLTF(file, outputFile, {
81
82
  config,
82
83
  packedFiles: set,
83
84
  stats,
@@ -86,6 +87,9 @@ Compress a single glTF file. The input file is compressed and written to the out
86
87
  logger: logger,
87
88
  file_stats: file_stats,
88
89
  });
90
+ if (res === false) {
91
+ process.exit(ERROR_CODES.PACKING_FAILED);
92
+ }
89
93
  });
90
94
  printStats(stats);
91
95
  console.log("Stats: ", options);
@@ -136,6 +140,9 @@ Each version will be compressed and written to the output directory.
136
140
  config,
137
141
  debug: false,
138
142
  useCache: true,
143
+ }).catch(err => {
144
+ logger.error(err);
145
+ process.exit(ERROR_CODES.PROGRESSIVE_FAILED);
139
146
  });
140
147
  const opts = {
141
148
  config,
@@ -148,10 +155,14 @@ Each version will be compressed and written to the output directory.
148
155
  };
149
156
  for (const res of progressive_results) {
150
157
  logger.info("> Compress " + res);
151
- await packGLTF(res, res, opts);
158
+ if (await packGLTF(res, res, opts) === false) {
159
+ process.exit(ERROR_CODES.PACKING_FAILED);
160
+ }
152
161
  }
153
162
  logger.info("> Compress " + file);
154
- await packGLTF(file, file, opts);
163
+ if (await packGLTF(file, file, opts) === false) {
164
+ process.exit(ERROR_CODES.PACKING_FAILED);
165
+ }
155
166
  });
156
167
  printStats(stats);
157
168
  if (options.outputStats) {
@@ -0,0 +1,5 @@
1
+ export declare const ERROR_CODES: {
2
+ UNKNOWN_ERROR: number;
3
+ PACKING_FAILED: number;
4
+ PROGRESSIVE_FAILED: number;
5
+ };
@@ -0,0 +1,5 @@
1
+ export const ERROR_CODES = {
2
+ UNKNOWN_ERROR: 1,
3
+ PACKING_FAILED: 2,
4
+ PROGRESSIVE_FAILED: 3,
5
+ };
@@ -5,3 +5,4 @@ export * from "./transforms/index.js";
5
5
  export * from "./extensions/index.js";
6
6
  export * from "./cache/index.js";
7
7
  export * from "./scripts/index.js";
8
+ export * from "./constants.js";
package/dist/src/index.js CHANGED
@@ -5,3 +5,4 @@ export * from "./transforms/index.js";
5
5
  export * from "./extensions/index.js";
6
6
  export * from "./cache/index.js";
7
7
  export * from "./scripts/index.js";
8
+ export * from "./constants.js";
@@ -22,7 +22,7 @@ export async function packGLTF(inputFile, outputFile, options) {
22
22
  return;
23
23
  }
24
24
  if (debug && inputFile.includes(".debug.")) {
25
- return;
25
+ return true;
26
26
  }
27
27
  // check if it's in the cache.
28
28
  // We only need to check mesh LOD files because image LODs are cache via our toktx transform
@@ -36,12 +36,12 @@ export async function packGLTF(inputFile, outputFile, options) {
36
36
  if (cached) {
37
37
  logger.info(`→ Loaded compressed file from cache: \"${path.basename(inputFile)}\"`);
38
38
  writeFileSync(inputFile, cached);
39
- return;
39
+ return true;
40
40
  }
41
41
  }
42
42
  if (packedFiles) {
43
43
  if (packedFiles.has(inputFile))
44
- return;
44
+ return true;
45
45
  packedFiles.add(inputFile);
46
46
  }
47
47
  try {
@@ -53,15 +53,7 @@ async function onProcess(file, opts) {
53
53
  'draco3d.decoder': await draco3d.createDecoderModule(),
54
54
  'draco3d.encoder': await draco3d.createEncoderModule(),
55
55
  });
56
- const document = await io.read(file).catch((err) => {
57
- // Log this message as a warning, it happens when trying to run on a already compressed gltf file (e.g. pre-processed. When logging an error we fail the build which is not desired)
58
- if (err.message === "Cannot read properties of undefined (reading 'DT_FLOAT32')") {
59
- console.log("WARN: \"" + err.message + "\" at \"" + file + "\"");
60
- }
61
- else
62
- console.log("ERR: \"" + err.message + "\" at \"" + file + "\"\nStacktrace:\n" + err.stack);
63
- return;
64
- });
56
+ let document = await io.read(file);
65
57
  if (document) {
66
58
  if (opts.debug === true) {
67
59
  if (file.includes(".debug.")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/gltf-build-pipeline",
3
- "version": "1.6.0-alpha.4",
3
+ "version": "1.6.0-alpha.6",
4
4
  "description": "Pipeline and tools for optimizing gltf files using gltf-transform and compression settings within glTF extensions",
5
5
  "main": "index.mjs",
6
6
  "type": "module",
@@ -51,7 +51,8 @@
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/node": "^18.7.23",
54
- "npm-watch": "^0.11.0",
54
+ "nodemon": "^3.1.2",
55
+ "npm-watch": "^0.13.0",
55
56
  "typescript": "^4.9.5"
56
57
  },
57
58
  "author": {
@@ -63,4 +64,4 @@
63
64
  "type": "git",
64
65
  "url": "git+https://github.com/needle-tools/needle-gltf-extensions.git"
65
66
  }
66
- }
67
+ }