@remvst/asset-catalog 1.0.0 → 1.0.2
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/lib/generate-image-catalog.js +0 -0
- package/lib/generate-sound-catalog.js +0 -3
- package/lib/tree.js +2 -1
- package/lib/utils.d.ts +0 -3
- package/lib/utils.js +1 -23
- package/package.json +3 -2
- package/src/generate-sound-catalog.ts +0 -2
|
File without changes
|
|
@@ -55,8 +55,6 @@ async function main() {
|
|
|
55
55
|
catch (e) { }
|
|
56
56
|
const files = await (0, utils_1.allFiles)(argv.assetDir);
|
|
57
57
|
const sounds = files.filter(file => extensions.indexOf((0, path_1.extname)(file)) >= 0);
|
|
58
|
-
console.log(sounds);
|
|
59
|
-
// const categories = new Map<string, Set<string>>();
|
|
60
58
|
const defs = new Map();
|
|
61
59
|
for (const sound of sounds) {
|
|
62
60
|
const category = (0, utils_1.categoryPath)(argv.assetDir, sound).join('_');
|
|
@@ -70,7 +68,6 @@ async function main() {
|
|
|
70
68
|
}
|
|
71
69
|
defs.get(category).get(filenameWithoutExt).add(sound);
|
|
72
70
|
}
|
|
73
|
-
console.log(defs);
|
|
74
71
|
const imports = [];
|
|
75
72
|
const definitions = [];
|
|
76
73
|
const funcs = [];
|
package/lib/tree.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateTree = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
4
5
|
const utils_1 = require("./utils");
|
|
5
6
|
async function generateTree(dir, files) {
|
|
6
7
|
const tree = new Map();
|
|
@@ -12,7 +13,7 @@ async function generateTree(dir, files) {
|
|
|
12
13
|
}
|
|
13
14
|
subtree = subtree.get(category);
|
|
14
15
|
}
|
|
15
|
-
subtree.set((0,
|
|
16
|
+
subtree.set((0, path_1.basename)(file).replace('.file', ''), file);
|
|
16
17
|
}
|
|
17
18
|
return tree;
|
|
18
19
|
}
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
export declare function allFiles(path: string): Promise<string[]>;
|
|
2
|
-
export declare function basename(path: string): string;
|
|
3
2
|
export declare function sanitize(string: string): string;
|
|
4
|
-
export declare function execShellCommand(cmd: string): Promise<string>;
|
|
5
|
-
export declare function toUpperSnakeCase(str: string): string;
|
|
6
3
|
export declare function camelize(str: string): string;
|
|
7
4
|
export declare function lowerCamelize(str: string): string;
|
|
8
5
|
export declare function categoryPath(assetDir: string, png: string): string[];
|
package/lib/utils.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.categoryPath = exports.lowerCamelize = exports.camelize = exports.
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
3
|
+
exports.categoryPath = exports.lowerCamelize = exports.camelize = exports.sanitize = exports.allFiles = void 0;
|
|
5
4
|
const fs_1 = require("fs");
|
|
6
5
|
const path_1 = require("path");
|
|
7
6
|
async function allFiles(path) {
|
|
@@ -22,31 +21,10 @@ async function allFiles(path) {
|
|
|
22
21
|
return res;
|
|
23
22
|
}
|
|
24
23
|
exports.allFiles = allFiles;
|
|
25
|
-
function basename(path) {
|
|
26
|
-
const filename = path.slice(path.lastIndexOf('/') + 1);
|
|
27
|
-
return filename.slice(0, filename.lastIndexOf('.'));
|
|
28
|
-
}
|
|
29
|
-
exports.basename = basename;
|
|
30
24
|
function sanitize(string) {
|
|
31
25
|
return string.replace(/[^a-zA-Z0-9]/g, '_');
|
|
32
26
|
}
|
|
33
27
|
exports.sanitize = sanitize;
|
|
34
|
-
function execShellCommand(cmd) {
|
|
35
|
-
return new Promise((resolve, reject) => {
|
|
36
|
-
(0, child_process_1.exec)(cmd, (error, stdout, stderr) => {
|
|
37
|
-
if (error) {
|
|
38
|
-
reject(error);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
resolve(stdout ? stdout : stderr);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
exports.execShellCommand = execShellCommand;
|
|
46
|
-
function toUpperSnakeCase(str) {
|
|
47
|
-
return str.toUpperCase().replace(/[^A-Z0-9]/g, '_');
|
|
48
|
-
}
|
|
49
|
-
exports.toUpperSnakeCase = toUpperSnakeCase;
|
|
50
28
|
function camelize(str) {
|
|
51
29
|
return str.split(/[^a-z0-9]/gi).map(word => word.charAt(0).toUpperCase() + word.slice(1)).join('');
|
|
52
30
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remvst/asset-catalog",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"bin": {
|
|
6
6
|
"generate-image-catalog": "./lib/generate-image-catalog.js",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"build": "rm -rf lib && tsc",
|
|
11
11
|
"test:images": "ts-node src/generate-image-catalog.ts --assetDir=./testData --outFile=testOut/images.ts",
|
|
12
12
|
"test:sounds": "ts-node src/generate-sound-catalog.ts --assetDir=./testData/sounds --outFile=testOut/sounds.ts",
|
|
13
|
-
"test": "npm run test:images && npm run test:sounds"
|
|
13
|
+
"test": "npm run test:images && npm run test:sounds",
|
|
14
|
+
"prepublishOnly": "npm i && npm run build"
|
|
14
15
|
},
|
|
15
16
|
"author": "Rémi Vansteelandt",
|
|
16
17
|
"license": "UNLICENSED",
|