ttmg-pack 0.4.4 → 0.4.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/CHANGELOG.md +400 -0
- package/__TEST__/tests/fixtures/check-project/non-unity/src/game.js +1 -0
- package/__TEST__/tests/fixtures/check-project/non-unity/src/game.json +3 -0
- package/__TEST__/tests/fixtures/check-project/subpackages-camel-case/src/game.js +1 -0
- package/__TEST__/tests/fixtures/check-project/subpackages-camel-case/src/game.json +4 -0
- package/__TEST__/tests/fixtures/check-project/unity-large-config-disabled/src/game.js +1 -0
- package/__TEST__/tests/fixtures/check-project/unity-large-config-disabled/src/game.json +4 -0
- package/__TEST__/tests/fixtures/check-project/unity-large-config-disabled/src/webgl-wasm-split.json +3 -0
- package/__TEST__/tests/fixtures/check-project/unity-large-config-enabled/src/game.js +1 -0
- package/__TEST__/tests/fixtures/check-project/unity-large-config-enabled/src/game.json +4 -0
- package/__TEST__/tests/fixtures/check-project/unity-large-config-enabled/src/webgl-wasm-split.json +3 -0
- package/__TEST__/tests/fixtures/check-project/unity-large-no-config/src/game.js +1 -0
- package/__TEST__/tests/fixtures/check-project/unity-large-no-config/src/game.json +4 -0
- package/__TEST__/tests/fixtures/check-project/unity-small/src/game.js +1 -0
- package/__TEST__/tests/fixtures/check-project/unity-small/src/game.json +4 -0
- package/__TEST__/tests/fixtures/game-cocos/game.json +3 -0
- package/__TEST__/tests/fixtures/game-invalid-json/game.json +1 -0
- package/__TEST__/tests/fixtures/game-no-config/game.js +1 -0
- package/__TEST__/tests/fixtures/game-no-engine/game.json +3 -0
- package/__TEST__/tests/fixtures/game-unity/game.json +15 -0
- package/__TEST__/tests/libs/checkProject.test.js +68 -0
- package/__TEST__/tests/runner-simple.js +120 -0
- package/__TEST__/tests/runner.js +102 -0
- package/__TEST__/tests/utils/Deferred.test.js +69 -0
- package/__TEST__/tests/utils/asyncPool.test.js +48 -0
- package/__TEST__/tests/utils/getCheckConfig.test.js +24 -0
- package/__TEST__/tests/utils/getGameEngine.test.js +32 -0
- package/__TEST__/tests/utils/getIndependentPackagesConfig.test.js +27 -0
- package/__TEST__/tests/utils/getMd5.test.js +31 -0
- package/__TEST__/tests/utils/getSubpackagesConfig.test.js +26 -0
- package/__TEST__/tests/utils/unity.test.js +30 -0
- package/dist/index.js +12 -10
- package/dist/index.js.map +1 -1
- package/dist/libs/checkPkgs/checkPkgPath.d.ts +1 -0
- package/dist/libs/extractPkgs/hasAnyNodeModulesShallow.d.ts +1 -0
- package/dist/libs/extractPkgs/index.d.ts +6 -0
- package/dist/libs/makePkgs/extract/NodeModuleExtractor.d.ts +39 -0
- package/dist/libs/makePkgs/extract/hasAnyNodeModulesShallow.d.ts +1 -0
- package/dist/libs/makePkgs/extract/index.d.ts +6 -0
- package/dist/libs/makePkgs/extract.d.ts +4 -0
- package/dist/utils/NodeModuleExtractor.d.ts +38 -0
- package/dist/utils/overrideConfig.d.ts +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const tests = [];
|
|
5
|
+
const describeStack = [];
|
|
6
|
+
let currentDescribe = null;
|
|
7
|
+
|
|
8
|
+
function describe(name, fn) {
|
|
9
|
+
const suite = { name, tests: [], children: [] };
|
|
10
|
+
if (currentDescribe) {
|
|
11
|
+
currentDescribe.children.push(suite);
|
|
12
|
+
} else {
|
|
13
|
+
tests.push(suite);
|
|
14
|
+
}
|
|
15
|
+
describeStack.push(currentDescribe);
|
|
16
|
+
currentDescribe = suite;
|
|
17
|
+
try {
|
|
18
|
+
fn();
|
|
19
|
+
} finally {
|
|
20
|
+
currentDescribe = describeStack.pop();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function it(name, fn) {
|
|
25
|
+
if (!currentDescribe) {
|
|
26
|
+
throw new Error('it() must be called inside describe()');
|
|
27
|
+
}
|
|
28
|
+
currentDescribe.tests.push({ name, fn });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let passed = 0;
|
|
32
|
+
let failed = 0;
|
|
33
|
+
|
|
34
|
+
async function runSuite(suite, indent = 0) {
|
|
35
|
+
console.log(`${' '.repeat(indent)}${suite.name}`);
|
|
36
|
+
for (const test of suite.tests) {
|
|
37
|
+
try {
|
|
38
|
+
if (test.fn.constructor.name === 'AsyncFunction') {
|
|
39
|
+
await test.fn();
|
|
40
|
+
} else {
|
|
41
|
+
test.fn();
|
|
42
|
+
}
|
|
43
|
+
console.log(`${' '.repeat(indent + 1)}✓ ${test.name}`);
|
|
44
|
+
passed++;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.log(`${' '.repeat(indent + 1)}✗ ${test.name}`);
|
|
47
|
+
console.log(`${' '.repeat(indent + 2)}${error.message}`);
|
|
48
|
+
if (error.stack) {
|
|
49
|
+
console.log(`${' '.repeat(indent + 2)}${error.stack.split('\n').slice(1).join('\n' + ' '.repeat(indent + 2))}`);
|
|
50
|
+
}
|
|
51
|
+
failed++;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
for (const child of suite.children) {
|
|
55
|
+
await runSuite(child, indent + 1);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function runTests() {
|
|
60
|
+
console.log('========================================');
|
|
61
|
+
console.log('Running unit tests');
|
|
62
|
+
console.log('========================================\n');
|
|
63
|
+
|
|
64
|
+
const testFiles = [
|
|
65
|
+
'utils/getMd5.test.js',
|
|
66
|
+
'utils/Deferred.test.js',
|
|
67
|
+
'utils/getGameEngine.test.js',
|
|
68
|
+
'utils/getSubpackagesConfig.test.js',
|
|
69
|
+
'utils/getIndependentPackagesConfig.test.js',
|
|
70
|
+
'utils/asyncPool.test.js',
|
|
71
|
+
'utils/unity.test.js',
|
|
72
|
+
'utils/getCheckConfig.test.js',
|
|
73
|
+
'libs/checkProject.test.js'
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
for (const file of testFiles) {
|
|
77
|
+
const testPath = path.join(__dirname, file);
|
|
78
|
+
if (fs.existsSync(testPath)) {
|
|
79
|
+
console.log(`Loading tests from: ${file}`);
|
|
80
|
+
require(testPath);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
console.log('\n');
|
|
85
|
+
|
|
86
|
+
for (const suite of tests) {
|
|
87
|
+
await runSuite(suite);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
console.log('\n========================================');
|
|
91
|
+
console.log('Test Summary:');
|
|
92
|
+
console.log(` Passed: ${passed}`);
|
|
93
|
+
console.log(` Failed: ${failed}`);
|
|
94
|
+
console.log('========================================');
|
|
95
|
+
|
|
96
|
+
process.exit(failed > 0 ? 1 : 0);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
global.describe = describe;
|
|
100
|
+
global.it = it;
|
|
101
|
+
|
|
102
|
+
runTests();
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const assert = require('assert');
|
|
2
|
+
const { Deferred } = require('../../../dist/utils/Deferred');
|
|
3
|
+
|
|
4
|
+
describe('Deferred', function() {
|
|
5
|
+
it('should create a deferred object with promise', function() {
|
|
6
|
+
const deferred = new Deferred();
|
|
7
|
+
assert(deferred.promise instanceof Promise);
|
|
8
|
+
assert.strictEqual(typeof deferred.resolve, 'function');
|
|
9
|
+
assert.strictEqual(typeof deferred.reject, 'function');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should resolve successfully', async function() {
|
|
13
|
+
const deferred = new Deferred();
|
|
14
|
+
const testValue = 'success';
|
|
15
|
+
|
|
16
|
+
setTimeout(() => deferred.resolve(testValue), 10);
|
|
17
|
+
|
|
18
|
+
const result = await deferred.promise;
|
|
19
|
+
assert.strictEqual(result, testValue);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should reject with error', async function() {
|
|
23
|
+
const deferred = new Deferred();
|
|
24
|
+
const testError = new Error('test error');
|
|
25
|
+
|
|
26
|
+
setTimeout(() => deferred.reject(testError), 10);
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
await deferred.promise;
|
|
30
|
+
assert.fail('Promise should have rejected');
|
|
31
|
+
} catch (error) {
|
|
32
|
+
assert.strictEqual(error, testError);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should support then method', async function() {
|
|
37
|
+
const deferred = new Deferred();
|
|
38
|
+
const testValue = 'test';
|
|
39
|
+
|
|
40
|
+
setTimeout(() => deferred.resolve(testValue), 10);
|
|
41
|
+
|
|
42
|
+
const result = await deferred.then(val => val.toUpperCase());
|
|
43
|
+
assert.strictEqual(result, 'TEST');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should support catch method', async function() {
|
|
47
|
+
const deferred = new Deferred();
|
|
48
|
+
const testError = new Error('catch me');
|
|
49
|
+
|
|
50
|
+
setTimeout(() => deferred.reject(testError), 10);
|
|
51
|
+
|
|
52
|
+
const caught = await deferred.catch(err => err.message);
|
|
53
|
+
assert.strictEqual(caught, 'catch me');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('should handle resolve called multiple times', async function() {
|
|
57
|
+
const deferred = new Deferred();
|
|
58
|
+
let resolveCount = 0;
|
|
59
|
+
|
|
60
|
+
deferred.promise.then(() => resolveCount++);
|
|
61
|
+
|
|
62
|
+
deferred.resolve('first');
|
|
63
|
+
deferred.resolve('second');
|
|
64
|
+
|
|
65
|
+
await new Promise(resolve => setTimeout(resolve, 10));
|
|
66
|
+
|
|
67
|
+
assert.strictEqual(resolveCount, 1);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const assert = require('assert');
|
|
2
|
+
const { asyncPool } = require('../../../dist/utils/asyncPool');
|
|
3
|
+
|
|
4
|
+
describe('asyncPool', function() {
|
|
5
|
+
it('should execute all tasks with pool limit', async function() {
|
|
6
|
+
const tasks = [1, 2, 3, 4, 5];
|
|
7
|
+
const results = [];
|
|
8
|
+
|
|
9
|
+
const iteratorFn = async (item) => {
|
|
10
|
+
await new Promise(resolve => setTimeout(resolve, 10));
|
|
11
|
+
results.push(item);
|
|
12
|
+
return item * 2;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const finalResults = await asyncPool(2, tasks, iteratorFn);
|
|
16
|
+
|
|
17
|
+
assert.deepStrictEqual(finalResults, [2, 4, 6, 8, 10]);
|
|
18
|
+
assert.strictEqual(results.length, 5);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should handle empty array', async function() {
|
|
22
|
+
const results = await asyncPool(5, [], async () => {});
|
|
23
|
+
assert.deepStrictEqual(results, []);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should handle pool limit larger than array length', async function() {
|
|
27
|
+
const tasks = [1, 2, 3];
|
|
28
|
+
const iteratorFn = async (item) => item;
|
|
29
|
+
|
|
30
|
+
const results = await asyncPool(10, tasks, iteratorFn);
|
|
31
|
+
assert.deepStrictEqual(results, [1, 2, 3]);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should propagate errors', async function() {
|
|
35
|
+
const tasks = [1, 2, 3];
|
|
36
|
+
const iteratorFn = async (item) => {
|
|
37
|
+
if (item === 2) throw new Error('Test error');
|
|
38
|
+
return item;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
await asyncPool(2, tasks, iteratorFn);
|
|
43
|
+
assert.fail('Should have thrown an error');
|
|
44
|
+
} catch (error) {
|
|
45
|
+
assert.strictEqual(error.message, 'Test error');
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const assert = require('assert');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { getCheckConfig } = require('../../../dist/utils/getCheckConfig');
|
|
4
|
+
const { GAME_PKG_SIZE_LIMIT } = require('../../../dist/constants');
|
|
5
|
+
|
|
6
|
+
const fixturesPath = path.join(__dirname, '../fixtures');
|
|
7
|
+
|
|
8
|
+
describe('getCheckConfig', function() {
|
|
9
|
+
it('should return unity config for unity engine', function() {
|
|
10
|
+
const config = getCheckConfig({
|
|
11
|
+
entry: path.join(fixturesPath, 'game-unity')
|
|
12
|
+
});
|
|
13
|
+
assert.strictEqual(config.pkgSizeLimit, GAME_PKG_SIZE_LIMIT.unity.project);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('should return default config for non-unity engine', function() {
|
|
17
|
+
const config = getCheckConfig({
|
|
18
|
+
entry: path.join(fixturesPath, 'game-cocos')
|
|
19
|
+
});
|
|
20
|
+
assert.strictEqual(config.pkgSizeLimit, 30 * 1024 * 1024);
|
|
21
|
+
assert.strictEqual(config.mainPkgSizeLimit, 4 * 1024 * 1024);
|
|
22
|
+
assert.strictEqual(config.independentSubPkgSizeLimit, 4 * 1024 * 1024);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const assert = require('assert');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { getGameEngine } = require('../../../dist/utils/getGameEngine');
|
|
4
|
+
|
|
5
|
+
const fixturesPath = path.join(__dirname, '../fixtures');
|
|
6
|
+
|
|
7
|
+
describe('getGameEngine', function() {
|
|
8
|
+
it('should return unity when gameEngine is unity', function() {
|
|
9
|
+
const result = getGameEngine(path.join(fixturesPath, 'game-unity'));
|
|
10
|
+
assert.strictEqual(result, 'unity');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should return cocos when gameEngine is cocos', function() {
|
|
14
|
+
const result = getGameEngine(path.join(fixturesPath, 'game-cocos'));
|
|
15
|
+
assert.strictEqual(result, 'cocos');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should return unknown when game.json does not exist', function() {
|
|
19
|
+
const result = getGameEngine(path.join(fixturesPath, 'game-no-config'));
|
|
20
|
+
assert.strictEqual(result, 'unknown');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should return unknown when game.json has invalid JSON', function() {
|
|
24
|
+
const result = getGameEngine(path.join(fixturesPath, 'game-invalid-json'));
|
|
25
|
+
assert.strictEqual(result, 'unknown');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should return unknown when game.json does not have gameEngine field', function() {
|
|
29
|
+
const result = getGameEngine(path.join(fixturesPath, 'game-no-engine'));
|
|
30
|
+
assert.strictEqual(result, 'unknown');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const assert = require('assert');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { getIndependentPackagesConfig } = require('../../../dist/utils/getIndependentPackagesConfig');
|
|
4
|
+
|
|
5
|
+
const fixturesPath = path.join(__dirname, '../fixtures');
|
|
6
|
+
|
|
7
|
+
describe('getIndependentPackagesConfig', function() {
|
|
8
|
+
it('should return independent subpackages', function() {
|
|
9
|
+
const result = getIndependentPackagesConfig(path.join(fixturesPath, 'game-unity'));
|
|
10
|
+
assert(Array.isArray(result));
|
|
11
|
+
assert.strictEqual(result.length, 1);
|
|
12
|
+
assert.strictEqual(result[0].name, 'sub2');
|
|
13
|
+
assert.strictEqual(result[0].independent, true);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('should return empty array when game.json does not exist', function() {
|
|
17
|
+
const result = getIndependentPackagesConfig(path.join(fixturesPath, 'game-no-config'));
|
|
18
|
+
assert(Array.isArray(result));
|
|
19
|
+
assert.strictEqual(result.length, 0);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should return empty array when game.json has invalid JSON', function() {
|
|
23
|
+
const result = getIndependentPackagesConfig(path.join(fixturesPath, 'game-invalid-json'));
|
|
24
|
+
assert(Array.isArray(result));
|
|
25
|
+
assert.strictEqual(result.length, 0);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const assert = require('assert');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const { getMd5 } = require('../../../dist/utils/getMd5');
|
|
5
|
+
|
|
6
|
+
describe('getMd5', function() {
|
|
7
|
+
it('should return correct MD5 hash for string input', function() {
|
|
8
|
+
const testStr = 'hello world';
|
|
9
|
+
const expected = '5eb63bbbe01eeed093cb22bb8f5acdc3';
|
|
10
|
+
const result = getMd5(testStr);
|
|
11
|
+
assert.strictEqual(result, expected);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should return consistent hash for same input', function() {
|
|
15
|
+
const testStr = 'test string';
|
|
16
|
+
const result1 = getMd5(testStr);
|
|
17
|
+
const result2 = getMd5(testStr);
|
|
18
|
+
assert.strictEqual(result1, result2);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should return different hash for different input', function() {
|
|
22
|
+
const result1 = getMd5('string1');
|
|
23
|
+
const result2 = getMd5('string2');
|
|
24
|
+
assert.notStrictEqual(result1, result2);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should handle empty string', function() {
|
|
28
|
+
const result = getMd5('');
|
|
29
|
+
assert.strictEqual(result, 'd41d8cd98f00b204e9800998ecf8427e');
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const assert = require('assert');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { getSubpackagesConfig } = require('../../../dist/utils/getSubpackagesConfig');
|
|
4
|
+
|
|
5
|
+
const fixturesPath = path.join(__dirname, '../fixtures');
|
|
6
|
+
|
|
7
|
+
describe('getSubpackagesConfig', function() {
|
|
8
|
+
it('should return non-independent subpackages', function() {
|
|
9
|
+
const result = getSubpackagesConfig(path.join(fixturesPath, 'game-unity'));
|
|
10
|
+
assert(Array.isArray(result));
|
|
11
|
+
assert.strictEqual(result.length, 1);
|
|
12
|
+
assert.strictEqual(result[0].name, 'sub1');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('should return empty array when game.json does not exist', function() {
|
|
16
|
+
const result = getSubpackagesConfig(path.join(fixturesPath, 'game-no-config'));
|
|
17
|
+
assert(Array.isArray(result));
|
|
18
|
+
assert.strictEqual(result.length, 0);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should return empty array when game.json has invalid JSON', function() {
|
|
22
|
+
const result = getSubpackagesConfig(path.join(fixturesPath, 'game-invalid-json'));
|
|
23
|
+
assert(Array.isArray(result));
|
|
24
|
+
assert.strictEqual(result.length, 0);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const assert = require('assert');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { isUnityEngine } = require('../../../dist/utils/unity');
|
|
4
|
+
const { getUnityBuildConfig } = require('../../../dist/utils/unity/getUnityBuildConfig');
|
|
5
|
+
const { GAME_PKG_SIZE_LIMIT } = require('../../../dist/constants');
|
|
6
|
+
|
|
7
|
+
const fixturesPath = path.join(__dirname, '../fixtures');
|
|
8
|
+
|
|
9
|
+
describe('Unity Utils', function() {
|
|
10
|
+
describe('isUnityEngine', function() {
|
|
11
|
+
it('should return true for unity engine', function() {
|
|
12
|
+
const result = isUnityEngine(path.join(fixturesPath, 'game-unity'));
|
|
13
|
+
assert.strictEqual(result, true);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('should return false for non-unity engine', function() {
|
|
17
|
+
const result = isUnityEngine(path.join(fixturesPath, 'game-cocos'));
|
|
18
|
+
assert.strictEqual(result, false);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('getUnityBuildConfig', function() {
|
|
23
|
+
it('should return unity build config', function() {
|
|
24
|
+
const config = getUnityBuildConfig();
|
|
25
|
+
assert.strictEqual(config.pkgSizeLimit, GAME_PKG_SIZE_LIMIT.unity.project);
|
|
26
|
+
assert.strictEqual(config.mainPkgSizeLimit, GAME_PKG_SIZE_LIMIT.unity.main);
|
|
27
|
+
assert.strictEqual(config.independentSubPkgSizeLimit, GAME_PKG_SIZE_LIMIT.unity.independent);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ==========================================
|
|
3
3
|
* @Description: ttmg pack
|
|
4
|
-
* @Version: 0.4.
|
|
4
|
+
* @Version: 0.4.5
|
|
5
5
|
* @Author: zhanghongyang.mocha
|
|
6
|
-
* @Date: 2026-03-
|
|
6
|
+
* @Date: 2026-03-22 15:35:16
|
|
7
7
|
* ==========================================
|
|
8
8
|
*/
|
|
9
9
|
'use strict';
|
|
@@ -1838,7 +1838,7 @@ async function getPluginInfo(params) {
|
|
|
1838
1838
|
return { url: meta.PackageCDNURL, md5: meta.PackageMD5 };
|
|
1839
1839
|
}
|
|
1840
1840
|
async function addDepsToPackages(gameEntry, outputDir, allDeps, config) {
|
|
1841
|
-
var _a;
|
|
1841
|
+
var _a, _b, _c;
|
|
1842
1842
|
const gamePackConfigPath = path.join(outputDir, GAME_PACK_CONFIG_FILE_NAME);
|
|
1843
1843
|
const gameJsonPath = path.join(gameEntry, GAME_ORIGIN_CONFIG_FILE_NAME);
|
|
1844
1844
|
let gamePackConfig;
|
|
@@ -1852,11 +1852,13 @@ async function addDepsToPackages(gameEntry, outputDir, allDeps, config) {
|
|
|
1852
1852
|
catch (error) {
|
|
1853
1853
|
throw new Error('[ttmg-pack] Failed to read package file game.json or packageConfig.json');
|
|
1854
1854
|
}
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1855
|
+
if (!((_a = config === null || config === void 0 ? void 0 : config.dev) === null || _a === void 0 ? void 0 : _a.enable)) {
|
|
1856
|
+
const unityDeps = ['data-package', 'StreamingAssets', 'wasmcode', 'wasmcode-android', 'wasmcode-ios'];
|
|
1857
|
+
for (const dep of unityDeps) {
|
|
1858
|
+
// 如果 game.json 的 subpackages 里有这个包,则添加进 __GAME__ 的 dependencies
|
|
1859
|
+
if (((_b = gameJson.subpackages) !== null && _b !== void 0 ? _b : []).some(pkg => pkg.name === dep)) {
|
|
1860
|
+
gamePackConfig.packages[GAME_MAIN_PACKAGE_NAME].dependencies.push(dep);
|
|
1861
|
+
}
|
|
1860
1862
|
}
|
|
1861
1863
|
}
|
|
1862
1864
|
for (const [pkgName, plugins] of Object.entries(allDeps)) {
|
|
@@ -1867,7 +1869,7 @@ async function addDepsToPackages(gameEntry, outputDir, allDeps, config) {
|
|
|
1867
1869
|
const pluginPkgName = `${pluginName}_${version}`;
|
|
1868
1870
|
let url = '';
|
|
1869
1871
|
let md5 = '';
|
|
1870
|
-
if (config === null || config === void 0 ? void 0 : config.dev) {
|
|
1872
|
+
if ((_c = config === null || config === void 0 ? void 0 : config.dev) === null || _c === void 0 ? void 0 : _c.enable) {
|
|
1871
1873
|
try {
|
|
1872
1874
|
const res = await getPluginInfo({
|
|
1873
1875
|
plugin_name: pluginName.toLowerCase(),
|
|
@@ -2418,7 +2420,7 @@ async function buildPkgs(config, context = {}) {
|
|
|
2418
2420
|
let startTime = Date.now();
|
|
2419
2421
|
logger.init(outputDir, true);
|
|
2420
2422
|
logger.info(t('log.build.version', {
|
|
2421
|
-
version: "0.4.
|
|
2423
|
+
version: "0.4.5",
|
|
2422
2424
|
}));
|
|
2423
2425
|
logger.info(t('log.build.start', { startTime }));
|
|
2424
2426
|
/**
|