@atb-as/generate-assets 13.1.0 → 13.2.0-rc.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.
- package/README.md +1 -1
- package/lib/bin.js +91 -40
- package/lib/bin.js.map +1 -1
- package/lib/generate.d.ts +4 -4
- package/lib/generate.js +208 -90
- package/lib/generate.js.map +1 -1
- package/lib/generateTs.js +100 -76
- package/lib/generateTs.js.map +1 -1
- package/lib/logger.js +9 -6
- package/lib/logger.js.map +1 -1
- package/lib/utils.d.ts +2 -2
- package/lib/utils.js +24 -24
- package/lib/utils.js.map +1 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ npx generate-assets -h
|
|
|
36
36
|
### Import through `ts`/`js`:
|
|
37
37
|
|
|
38
38
|
```ts
|
|
39
|
-
import generateAssets from '@atb-as/generate-assets';
|
|
39
|
+
import { generateAssets } from '@atb-as/generate-assets';
|
|
40
40
|
|
|
41
41
|
// This line will copy assets for selected orgId to selected destinationDirectory
|
|
42
42
|
generateAssets(
|
package/lib/bin.js
CHANGED
|
@@ -1,22 +1,58 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
14
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
+
function step(op) {
|
|
17
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
19
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
20
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
+
switch (op[0]) {
|
|
22
|
+
case 0: case 1: t = op; break;
|
|
23
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
+
default:
|
|
27
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
+
if (t[2]) _.ops.pop();
|
|
32
|
+
_.trys.pop(); continue;
|
|
33
|
+
}
|
|
34
|
+
op = body.call(thisArg, _);
|
|
35
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
3
39
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
40
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
41
|
};
|
|
6
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
43
|
+
var generate_1 = require("./generate");
|
|
44
|
+
var path_1 = __importDefault(require("path"));
|
|
45
|
+
var utils_1 = require("./utils");
|
|
46
|
+
var logger_1 = require("./logger");
|
|
47
|
+
var commander_1 = require("commander");
|
|
48
|
+
var generateTs_1 = require("./generateTs");
|
|
13
49
|
commander_1.program
|
|
14
50
|
.name('npx @atb-as/generate-assets')
|
|
15
51
|
.addArgument(new commander_1.Argument('<type>', 'Type of assets to generate')
|
|
16
52
|
.choices(['colors', 'all', 'mono'])
|
|
17
53
|
.argRequired())
|
|
18
54
|
.addArgument(new commander_1.Argument('<orgId>', 'Generate for specific organization')
|
|
19
|
-
.choices(generate_1.
|
|
55
|
+
.choices(generate_1.validOrgIds.map(utils_1.themeVariantAsString))
|
|
20
56
|
.argRequired())
|
|
21
57
|
.requiredOption('-o, --out-dir <output>', 'Output directory')
|
|
22
58
|
.option('-ts-o, --ts-out-dir <output>', 'Output directory for generated typescript')
|
|
@@ -27,49 +63,64 @@ commander_1.program
|
|
|
27
63
|
commander_1.program.showHelpAfterError();
|
|
28
64
|
commander_1.program.showSuggestionAfterError();
|
|
29
65
|
commander_1.program.parse();
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
66
|
+
var opts = commander_1.program.opts();
|
|
67
|
+
var assetType = commander_1.program.args[0];
|
|
68
|
+
var orgId = commander_1.program.args[1];
|
|
33
69
|
if (opts.debug)
|
|
34
70
|
(0, logger_1.setDebug)(true);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
71
|
+
var main = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
|
+
var outputFolder, potentialGlob, assets, generatedTsFile, e_1;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
outputFolder = path_1.default.join(process.cwd(), opts.outDir);
|
|
77
|
+
_a.label = 1;
|
|
78
|
+
case 1:
|
|
79
|
+
_a.trys.push([1, 5, , 6]);
|
|
80
|
+
potentialGlob = findPotentialGlobPattern(process.argv);
|
|
81
|
+
console.log("Writing assets for ".concat(orgId, " to ").concat(outputFolder));
|
|
82
|
+
return [4 /*yield*/, (0, generate_1.generateAssets)(assetType, (0, utils_1.stringAsThemeVariant)(orgId), outputFolder, {
|
|
83
|
+
patterns: potentialGlob,
|
|
84
|
+
generateMonoTheme: opts.generateMonoTheme,
|
|
85
|
+
})];
|
|
86
|
+
case 2:
|
|
87
|
+
assets = _a.sent();
|
|
88
|
+
if (opts.debug) {
|
|
89
|
+
console.log("Written ".concat(assets.length, " assets for ").concat(orgId, ":\n"));
|
|
90
|
+
console.log();
|
|
91
|
+
assets.forEach(function (i) { return console.log(i); });
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
console.log("Successfully written ".concat(assets.length, " assets for ").concat(orgId, " to ").concat(outputFolder));
|
|
95
|
+
}
|
|
96
|
+
if (!opts.generateTs) return [3 /*break*/, 4];
|
|
97
|
+
return [4 /*yield*/, (0, generateTs_1.generateTs)(assets, assetType, outputFolder, opts.tsOutDir)];
|
|
98
|
+
case 3:
|
|
99
|
+
generatedTsFile = _a.sent();
|
|
100
|
+
console.log("Generated typescript file: ".concat(generatedTsFile));
|
|
101
|
+
_a.label = 4;
|
|
102
|
+
case 4: return [3 /*break*/, 6];
|
|
103
|
+
case 5:
|
|
104
|
+
e_1 = _a.sent();
|
|
105
|
+
console.error(e_1 === null || e_1 === void 0 ? void 0 : e_1.message);
|
|
106
|
+
commander_1.program.help({ error: true });
|
|
107
|
+
return [3 /*break*/, 6];
|
|
108
|
+
case 6: return [2 /*return*/];
|
|
51
109
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
console.log(`Generated typescript file: ${generatedTsFile}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch (e) {
|
|
58
|
-
console.error(e?.message);
|
|
59
|
-
commander_1.program.help({ error: true });
|
|
60
|
-
}
|
|
61
|
-
};
|
|
110
|
+
});
|
|
111
|
+
}); };
|
|
62
112
|
main();
|
|
63
113
|
function findPotentialGlobPattern(args) {
|
|
64
|
-
|
|
65
|
-
|
|
114
|
+
var _a, _b;
|
|
115
|
+
for (var arg in args) {
|
|
116
|
+
if (!((_a = args[arg]) === null || _a === void 0 ? void 0 : _a.startsWith('--glob')) && !((_b = args[arg]) === null || _b === void 0 ? void 0 : _b.startsWith('-g')))
|
|
66
117
|
continue;
|
|
67
118
|
// Is glob, check for valid next argument or if using =
|
|
68
119
|
if (args[arg].includes('=')) {
|
|
69
|
-
|
|
120
|
+
var _c = args[arg].split('='), glob = _c[1];
|
|
70
121
|
return glob;
|
|
71
122
|
}
|
|
72
|
-
|
|
123
|
+
var potentialGlob = args[Number(arg) + 1];
|
|
73
124
|
if (!potentialGlob) {
|
|
74
125
|
throw new Error('Missing argument to --glob.');
|
|
75
126
|
}
|
package/lib/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,uCAAmE;AACnE,8CAA2B;AAC3B,iCAA8E;AAC9E,mCAAkC;AAElC,uCAA4C;AAC5C,2CAAwC;AAWxC,mBAAO;KACJ,IA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,CAAC;QACrB,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,GAAG,CAAC,0CAAE,UAAU,CAAC,QAAQ,CAAC,CAAA,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,GAAG,CAAC,0CAAE,UAAU,CAAC,IAAI,CAAC,CAAA;YAClE,SAAS;QAEX,uDAAuD;QACvD,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACtB,IAAA,KAAW,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAA5B,IAAI,QAAwB,CAAC;YACtC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5C,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/lib/generate.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ThemeVariant } from '@atb-as/theme
|
|
2
|
-
export declare const
|
|
1
|
+
import { ThemeVariant } from '@atb-as/theme';
|
|
2
|
+
export declare const validOrgIds: ThemeVariant[];
|
|
3
3
|
export declare const searchGlob = "**/*.{svg,png,jpg,jpeg,ico}";
|
|
4
4
|
export declare const searchGlobSvg = "**/*.svg";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
type AssetTypes = 'colors' | 'mono' | 'all';
|
|
6
|
+
type Options = {
|
|
7
7
|
generateMonoTheme?: boolean;
|
|
8
8
|
onlyOutputMono?: boolean;
|
|
9
9
|
patterns?: string | readonly string[];
|
package/lib/generate.js
CHANGED
|
@@ -1,115 +1,233 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
+
if (ar || !(i in from)) {
|
|
41
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
+
ar[i] = from[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
+
};
|
|
2
47
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
48
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
49
|
};
|
|
5
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
51
|
+
exports.searchGlobSvg = exports.searchGlob = exports.validOrgIds = void 0;
|
|
52
|
+
exports.generateAssets = generateAssets;
|
|
53
|
+
exports.generateMonoIconsInDestinationDirectory = generateMonoIconsInDestinationDirectory;
|
|
54
|
+
var promises_1 = __importDefault(require("fs/promises"));
|
|
55
|
+
var fs_1 = require("fs");
|
|
56
|
+
var path_1 = __importDefault(require("path"));
|
|
57
|
+
var theme_1 = require("@atb-as/theme");
|
|
58
|
+
var micromatch_1 = __importDefault(require("micromatch"));
|
|
59
|
+
var stream_editor_1 = require("stream-editor");
|
|
60
|
+
var utils_1 = require("./utils");
|
|
61
|
+
var logger_1 = require("./logger");
|
|
62
|
+
exports.validOrgIds = [
|
|
63
|
+
theme_1.ThemeVariant.AtB,
|
|
64
|
+
theme_1.ThemeVariant.Nfk,
|
|
65
|
+
theme_1.ThemeVariant.FRAM,
|
|
66
|
+
theme_1.ThemeVariant.Troms,
|
|
67
|
+
theme_1.ThemeVariant.Innlandet,
|
|
68
|
+
theme_1.ThemeVariant.VKT,
|
|
69
|
+
theme_1.ThemeVariant.Farte,
|
|
23
70
|
];
|
|
24
71
|
exports.searchGlob = '**/*.{svg,png,jpg,jpeg,ico}';
|
|
25
72
|
exports.searchGlobSvg = '**/*.svg';
|
|
26
|
-
|
|
73
|
+
var defaultOpts = {
|
|
27
74
|
generateMonoTheme: true,
|
|
28
75
|
onlyOutputMono: false,
|
|
29
76
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
(0
|
|
35
|
-
return (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
77
|
+
function generateAssets(assetType_1, orgId_1, destinationDirectory_1) {
|
|
78
|
+
return __awaiter(this, arguments, void 0, function (assetType, orgId, destinationDirectory, opts) {
|
|
79
|
+
var assetDir, fromBase, commonFiles, orgFiles, allFilesToBeCopied, potentiallyFiltered, allFiles, created, allExtraMonoIcons, _a, _b;
|
|
80
|
+
var _this = this;
|
|
81
|
+
if (opts === void 0) { opts = defaultOpts; }
|
|
82
|
+
return __generator(this, function (_c) {
|
|
83
|
+
switch (_c.label) {
|
|
84
|
+
case 0:
|
|
85
|
+
assetDir = assetType == 'all' ? '{colors,mono}' : assetType;
|
|
86
|
+
fromBase = function () {
|
|
87
|
+
var p = [];
|
|
88
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
89
|
+
p[_i] = arguments[_i];
|
|
90
|
+
}
|
|
91
|
+
var fullPath = path_1.default.join.apply(path_1.default, __spreadArray(__spreadArray([__dirname,
|
|
92
|
+
'..',
|
|
93
|
+
'files'], p, false), [assetDir,
|
|
94
|
+
exports.searchGlob], false));
|
|
95
|
+
(0, logger_1.log)('searching for files in', fullPath);
|
|
96
|
+
return (0, utils_1.fgNormalizedForUnix)(fullPath);
|
|
97
|
+
};
|
|
98
|
+
if (!exports.validOrgIds.includes(orgId))
|
|
99
|
+
throw new Error("Invalid orgId provided, valid orgIds are ".concat(exports.validOrgIds));
|
|
100
|
+
return [4 /*yield*/, fromBase('common')];
|
|
101
|
+
case 1:
|
|
102
|
+
commonFiles = _c.sent();
|
|
103
|
+
return [4 /*yield*/, fromBase((0, utils_1.themeVariantAsString)(orgId))];
|
|
104
|
+
case 2:
|
|
105
|
+
orgFiles = _c.sent();
|
|
106
|
+
(0, logger_1.log)('Found common files:', commonFiles.length);
|
|
107
|
+
(0, logger_1.log)('Found org files for', orgId, ':', orgFiles.length);
|
|
108
|
+
(0, logger_1.log)('Merging files for ', assetType);
|
|
109
|
+
allFilesToBeCopied = mergeFiles(assetType, commonFiles, orgFiles);
|
|
110
|
+
(0, logger_1.log)('Found merged files:', allFilesToBeCopied.length);
|
|
111
|
+
potentiallyFiltered = opts.patterns
|
|
112
|
+
? (0, micromatch_1.default)(allFilesToBeCopied, opts.patterns)
|
|
113
|
+
: allFilesToBeCopied;
|
|
114
|
+
allFiles = potentiallyFiltered.map(function (absolutePath) { return __awaiter(_this, void 0, void 0, function () {
|
|
115
|
+
var relativePath, destinationPath;
|
|
116
|
+
return __generator(this, function (_a) {
|
|
117
|
+
switch (_a.label) {
|
|
118
|
+
case 0:
|
|
119
|
+
relativePath = path_1.default.normalize(getGeneralNameWithoutFullPath(assetType, absolutePath));
|
|
120
|
+
destinationPath = path_1.default.join(destinationDirectory, relativePath);
|
|
121
|
+
return [4 /*yield*/, promises_1.default.mkdir(path_1.default.dirname(destinationPath), { recursive: true })];
|
|
122
|
+
case 1:
|
|
123
|
+
_a.sent();
|
|
124
|
+
return [4 /*yield*/, promises_1.default.copyFile(path_1.default.normalize(absolutePath), destinationPath)];
|
|
125
|
+
case 2:
|
|
126
|
+
_a.sent();
|
|
127
|
+
return [2 /*return*/, destinationPath];
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}); });
|
|
131
|
+
(0, logger_1.log)('Total files before generated mono icons:', allFiles.length);
|
|
132
|
+
return [4 /*yield*/, Promise.all(allFiles)];
|
|
133
|
+
case 3:
|
|
134
|
+
created = _c.sent();
|
|
135
|
+
if (!(opts.generateMonoTheme && assetType !== 'colors')) return [3 /*break*/, 6];
|
|
136
|
+
return [4 /*yield*/, generateMonoIconsInDestinationDirectory(assetType, orgId, destinationDirectory)];
|
|
137
|
+
case 4:
|
|
138
|
+
allExtraMonoIcons = _c.sent();
|
|
139
|
+
_b = (_a = created).concat;
|
|
140
|
+
return [4 /*yield*/, Promise.all(allExtraMonoIcons)];
|
|
141
|
+
case 5:
|
|
142
|
+
created = _b.apply(_a, [_c.sent()]);
|
|
143
|
+
_c.label = 6;
|
|
144
|
+
case 6:
|
|
145
|
+
(0, logger_1.log)('Total files after generated mono icons:', created.length);
|
|
146
|
+
return [2 /*return*/, created];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
56
149
|
});
|
|
57
|
-
(0, logger_1.log)('Total files before generated mono icons:', allFiles.length);
|
|
58
|
-
let created = await Promise.all(allFiles);
|
|
59
|
-
if (opts.generateMonoTheme && assetType !== 'colors') {
|
|
60
|
-
const allExtraMonoIcons = await generateMonoIconsInDestinationDirectory(assetType, orgId, destinationDirectory);
|
|
61
|
-
created = created.concat(await Promise.all(allExtraMonoIcons));
|
|
62
|
-
}
|
|
63
|
-
(0, logger_1.log)('Total files after generated mono icons:', created.length);
|
|
64
|
-
return created;
|
|
65
150
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
151
|
+
function generateMonoIconsInDestinationDirectory(assetType, orgId, destinationDirectory) {
|
|
152
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
153
|
+
var themes, base, folder, darkBase, lightBase, files, _i, _a, entry;
|
|
154
|
+
return __generator(this, function (_b) {
|
|
155
|
+
switch (_b.label) {
|
|
156
|
+
case 0:
|
|
157
|
+
themes = (0, theme_1.createThemesFor)(orgId);
|
|
158
|
+
base = path_1.default.join(destinationDirectory, assetType === 'all' ? 'mono' : '');
|
|
159
|
+
folder = path_1.default.join(base, exports.searchGlobSvg);
|
|
160
|
+
darkBase = path_1.default.join(base, 'dark');
|
|
161
|
+
lightBase = path_1.default.join(base, 'light');
|
|
162
|
+
return [4 /*yield*/, promises_1.default.mkdir(darkBase, { recursive: true })];
|
|
163
|
+
case 1:
|
|
164
|
+
_b.sent();
|
|
165
|
+
return [4 /*yield*/, promises_1.default.mkdir(lightBase, { recursive: true })];
|
|
166
|
+
case 2:
|
|
167
|
+
_b.sent();
|
|
168
|
+
files = [];
|
|
169
|
+
_i = 0;
|
|
170
|
+
return [4 /*yield*/, (0, utils_1.fgNormalizedForUnix)(folder, {
|
|
171
|
+
// Avoid trying to convert what we have from before.
|
|
172
|
+
ignore: [darkBase, lightBase],
|
|
173
|
+
})];
|
|
174
|
+
case 3:
|
|
175
|
+
_a = _b.sent();
|
|
176
|
+
_b.label = 4;
|
|
177
|
+
case 4:
|
|
178
|
+
if (!(_i < _a.length)) return [3 /*break*/, 6];
|
|
179
|
+
entry = _a[_i];
|
|
180
|
+
files = files.concat([
|
|
181
|
+
rewriteAndSave('dark', themes, entry, base),
|
|
182
|
+
rewriteAndSave('light', themes, entry, base),
|
|
183
|
+
]);
|
|
184
|
+
_b.label = 5;
|
|
185
|
+
case 5:
|
|
186
|
+
_i++;
|
|
187
|
+
return [3 /*break*/, 4];
|
|
188
|
+
case 6: return [2 /*return*/, files];
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
});
|
|
87
192
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
193
|
+
function rewriteAndSave(color, themes, absoluteFile, monoIconsBase) {
|
|
194
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
195
|
+
var relativeFileName, filename, destinationDir, destination;
|
|
196
|
+
return __generator(this, function (_a) {
|
|
197
|
+
switch (_a.label) {
|
|
198
|
+
case 0:
|
|
199
|
+
relativeFileName = path_1.default.relative(monoIconsBase, absoluteFile);
|
|
200
|
+
filename = path_1.default.basename(relativeFileName);
|
|
201
|
+
destinationDir = path_1.default.join(monoIconsBase, color, path_1.default.dirname(relativeFileName));
|
|
202
|
+
return [4 /*yield*/, promises_1.default.mkdir(destinationDir, { recursive: true })];
|
|
203
|
+
case 1:
|
|
204
|
+
_a.sent();
|
|
205
|
+
destination = path_1.default.join(destinationDir, filename);
|
|
206
|
+
return [4 /*yield*/, (0, stream_editor_1.sed)({
|
|
207
|
+
from: (0, fs_1.createReadStream)(absoluteFile),
|
|
208
|
+
to: (0, fs_1.createWriteStream)(destination),
|
|
209
|
+
match: /((fill|stroke)\=\"(?:[^"]+)\")/,
|
|
210
|
+
replacement: "$2=\"".concat(themes[color].text.colors.primary, "\""),
|
|
211
|
+
})];
|
|
212
|
+
case 2:
|
|
213
|
+
_a.sent();
|
|
214
|
+
return [2 /*return*/, destination];
|
|
215
|
+
}
|
|
216
|
+
});
|
|
100
217
|
});
|
|
101
|
-
return destination;
|
|
102
218
|
}
|
|
103
219
|
function mergeFiles(assetType, commonFiles, orgFiles) {
|
|
104
|
-
|
|
105
|
-
|
|
220
|
+
var relativeOrgFiles = orgFiles.map(function (f) {
|
|
221
|
+
return getGeneralNameWithoutFullPath(assetType, f);
|
|
222
|
+
});
|
|
223
|
+
var commonsWithoutOverrides = commonFiles.filter(function (filepath) {
|
|
106
224
|
return !relativeOrgFiles.includes(getGeneralNameWithoutFullPath(assetType, filepath));
|
|
107
225
|
});
|
|
108
226
|
return commonsWithoutOverrides.concat(orgFiles);
|
|
109
227
|
}
|
|
110
228
|
function getGeneralNameWithoutFullPath(assetType, fullPath) {
|
|
111
|
-
|
|
112
|
-
|
|
229
|
+
var assetDir = assetType == 'all' ? '' : escapeRegex("/".concat(assetType));
|
|
230
|
+
var regexString = "^.*/files/[^/]+".concat(assetDir);
|
|
113
231
|
// Normalize to unix style instead if handling separator manually
|
|
114
232
|
return (0, utils_1.normalizeToUnix)(fullPath).replace(new RegExp(regexString), '');
|
|
115
233
|
}
|
package/lib/generate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,wCAiEC;AAED,0FA+BC;AA1ID,yDAA6B;AAC7B,yBAAuD;AACvD,8CAAwB;AAExB,uCAAoE;AAEpE,0DAAoC;AACp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,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,OAAG;yBACzD,CAAC,EAAA;;oBALF,SAKE,CAAC;oBAEH,sBAAO,WAAW,EAAC;;;;CACpB;AAED,SAAS,UAAU,CACjB,SAAqB,EACrB,WAAqB,EACrB,QAAkB;IAElB,IAAM,gBAAgB,GAAG,QAAQ,CAAC,GAAG,CAAC,UAAC,CAAC;QACtC,OAAA,6BAA6B,CAAC,SAAS,EAAE,CAAC,CAAC;IAA3C,CAA2C,CAC5C,CAAC;IACF,IAAM,uBAAuB,GAAG,WAAW,CAAC,MAAM,CAAC,UAAU,QAAQ;QACnE,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAC/B,6BAA6B,CAAC,SAAS,EAAE,QAAQ,CAAC,CACnD,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,uBAAuB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,6BAA6B,CACpC,SAAqB,EACrB,QAAgB;IAEhB,IAAM,QAAQ,GAAG,SAAS,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,WAAI,SAAS,CAAE,CAAC,CAAC;IACxE,IAAM,WAAW,GAAG,yBAAqB,QAAQ,CAAE,CAAC;IAEpD,iEAAiE;IACjE,OAAO,IAAA,uBAAe,EAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;AACxE,CAAC;AACD,SAAS,WAAW,CAAC,GAAW;IAC9B,OAAO,GAAG,CAAC,OAAO,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;AACvD,CAAC"}
|
package/lib/generateTs.js
CHANGED
|
@@ -1,79 +1,98 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
2
38
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
40
|
};
|
|
5
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generateTs = void 0;
|
|
7
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const utils_1 = require("./utils");
|
|
10
|
-
async function generateTs(allFiles, assetTypeInput, outputDir, tsOutput = outputDir) {
|
|
11
|
-
const data = generateData(allFiles, assetTypeInput, outputDir);
|
|
12
|
-
const generatedContents = template(data);
|
|
13
|
-
await promises_1.default.mkdir(tsOutput, { recursive: true });
|
|
14
|
-
const destinationFile = path_1.default.join(tsOutput, 'generated-icons.ts');
|
|
15
|
-
await promises_1.default.writeFile(destinationFile, generatedContents);
|
|
16
|
-
return destinationFile;
|
|
17
|
-
}
|
|
18
42
|
exports.generateTs = generateTs;
|
|
43
|
+
var promises_1 = __importDefault(require("fs/promises"));
|
|
44
|
+
var path_1 = __importDefault(require("path"));
|
|
45
|
+
var utils_1 = require("./utils");
|
|
46
|
+
function generateTs(allFiles_1, assetTypeInput_1, outputDir_1) {
|
|
47
|
+
return __awaiter(this, arguments, void 0, function (allFiles, assetTypeInput, outputDir, tsOutput) {
|
|
48
|
+
var data, generatedContents, destinationFile;
|
|
49
|
+
if (tsOutput === void 0) { tsOutput = outputDir; }
|
|
50
|
+
return __generator(this, function (_a) {
|
|
51
|
+
switch (_a.label) {
|
|
52
|
+
case 0:
|
|
53
|
+
data = generateData(allFiles, assetTypeInput, outputDir);
|
|
54
|
+
generatedContents = template(data);
|
|
55
|
+
return [4 /*yield*/, promises_1.default.mkdir(tsOutput, { recursive: true })];
|
|
56
|
+
case 1:
|
|
57
|
+
_a.sent();
|
|
58
|
+
destinationFile = path_1.default.join(tsOutput, 'generated-icons.ts');
|
|
59
|
+
return [4 /*yield*/, promises_1.default.writeFile(destinationFile, generatedContents)];
|
|
60
|
+
case 2:
|
|
61
|
+
_a.sent();
|
|
62
|
+
return [2 /*return*/, destinationFile];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
19
67
|
function template(data) {
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export const icons = ${JSON.stringify(data, null, 2)};
|
|
24
|
-
export type Icons = typeof icons;
|
|
25
|
-
|
|
26
|
-
export type ColorType = {
|
|
27
|
-
relative: string;
|
|
28
|
-
absolute: string;
|
|
29
|
-
assetType: 'colors';
|
|
30
|
-
colorType: 'illustrations' | 'images';
|
|
31
|
-
darkable: boolean;
|
|
32
|
-
id: string;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export type MonoType = {
|
|
36
|
-
relative: string;
|
|
37
|
-
absolute: string;
|
|
38
|
-
assetType: 'mono';
|
|
39
|
-
id: string;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export type IconType = ColorType | MonoType;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
${data.mono ? `export type MonoIcons = keyof Icons['mono'];` : ''}
|
|
46
|
-
${data.images ? `export type Images = keyof Icons['images'];` : ''}
|
|
47
|
-
${data.colorIcons ? `export type ColorIcons = keyof Icons['colorIcons'];` : ''}
|
|
48
|
-
${data.illustration
|
|
49
|
-
? `export type Illustrations = keyof Icons['illustration'];`
|
|
50
|
-
: ''}
|
|
51
|
-
`;
|
|
68
|
+
return "// NB! NB! NB!\n// AUTO GENERATED FILE. DON'T CHANGE\n// NB! NB! NB!\nexport const icons = ".concat(JSON.stringify(data, null, 2), ";\nexport type Icons = typeof icons;\n\nexport type ColorType = {\n relative: string;\n absolute: string;\n assetType: 'colors';\n colorType: 'illustrations' | 'images';\n darkable: boolean;\n id: string;\n};\n\nexport type MonoType = {\n relative: string;\n absolute: string;\n assetType: 'mono';\n id: string;\n};\n\nexport type IconType = ColorType | MonoType;\n\n\n").concat(data.mono ? "export type MonoIcons = keyof Icons['mono'];" : '', "\n").concat(data.images ? "export type Images = keyof Icons['images'];" : '', "\n").concat(data.colorIcons ? "export type ColorIcons = keyof Icons['colorIcons'];" : '', "\n").concat(data.illustration
|
|
69
|
+
? "export type Illustrations = keyof Icons['illustration'];"
|
|
70
|
+
: '', "\n");
|
|
52
71
|
}
|
|
53
72
|
function toUniqueObject(list) {
|
|
54
|
-
return pickBy(list, (i)
|
|
73
|
+
return pickBy(list, function (i) { return i.id; });
|
|
55
74
|
}
|
|
56
75
|
function generateData(allFiles, assetTypeInput, outputDir) {
|
|
57
|
-
|
|
58
|
-
.map((f)
|
|
76
|
+
var constructs = allFiles
|
|
77
|
+
.map(function (f) { return toTypeCoonstruct(f, assetTypeInput, outputDir); })
|
|
59
78
|
.filter(Boolean);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
? groupBy(groupedByMode.colors, (i)
|
|
79
|
+
var groupedByMode = groupBy(constructs, function (i) { return i.assetType; });
|
|
80
|
+
var mono = groupedByMode.mono;
|
|
81
|
+
var colors = groupedByMode.colors
|
|
82
|
+
? groupBy(groupedByMode.colors, function (i) { return i.colorType; })
|
|
64
83
|
: undefined;
|
|
65
84
|
return {
|
|
66
85
|
mono: mono ? toUniqueObject(mono) : undefined,
|
|
67
|
-
images: colors
|
|
68
|
-
colorIcons: colors
|
|
69
|
-
illustration: colors
|
|
86
|
+
images: (colors === null || colors === void 0 ? void 0 : colors.images) ? toUniqueObject(colors.images) : undefined,
|
|
87
|
+
colorIcons: (colors === null || colors === void 0 ? void 0 : colors.icons) ? toUniqueObject(colors.icons) : undefined,
|
|
88
|
+
illustration: (colors === null || colors === void 0 ? void 0 : colors.illustrations)
|
|
70
89
|
? toUniqueObject(colors.illustrations)
|
|
71
90
|
: undefined,
|
|
72
91
|
};
|
|
73
92
|
}
|
|
74
93
|
function toTypeCoonstruct(absolute, assetTypeInput, outputDir) {
|
|
75
|
-
|
|
76
|
-
|
|
94
|
+
var relative = absolute.replace(outputDir, '');
|
|
95
|
+
var assetType = assetTypeInput == 'all'
|
|
77
96
|
? relative.match(/^.?colors/)
|
|
78
97
|
? 'colors'
|
|
79
98
|
: 'mono'
|
|
@@ -84,8 +103,8 @@ function toTypeCoonstruct(absolute, assetTypeInput, outputDir) {
|
|
|
84
103
|
}
|
|
85
104
|
if (assetType == 'colors') {
|
|
86
105
|
return {
|
|
87
|
-
relative,
|
|
88
|
-
absolute,
|
|
106
|
+
relative: relative,
|
|
107
|
+
absolute: absolute,
|
|
89
108
|
assetType: 'colors',
|
|
90
109
|
colorType: getColorType(relative),
|
|
91
110
|
darkable: isDarkable(relative),
|
|
@@ -93,13 +112,13 @@ function toTypeCoonstruct(absolute, assetTypeInput, outputDir) {
|
|
|
93
112
|
};
|
|
94
113
|
}
|
|
95
114
|
return {
|
|
96
|
-
relative,
|
|
97
|
-
absolute,
|
|
115
|
+
relative: relative,
|
|
116
|
+
absolute: absolute,
|
|
98
117
|
assetType: 'mono',
|
|
99
118
|
id: toIDPath(relative),
|
|
100
119
|
};
|
|
101
120
|
}
|
|
102
|
-
|
|
121
|
+
var darkOrLight = /\/(?:dark|light)\//;
|
|
103
122
|
function toIDPath(relative) {
|
|
104
123
|
return (0, utils_1.normalizeToUnix)(relative)
|
|
105
124
|
.replace(darkOrLight, '/')
|
|
@@ -109,9 +128,10 @@ function isDarkable(relative) {
|
|
|
109
128
|
return relative.match(darkOrLight) !== null;
|
|
110
129
|
}
|
|
111
130
|
function getColorType(relative) {
|
|
112
|
-
|
|
131
|
+
var _a;
|
|
132
|
+
var colorType = (_a = (0, utils_1.normalizeToUnix)(relative)
|
|
113
133
|
// Extract the color type
|
|
114
|
-
.match(/^\/?(?:(?:mono|colors)\/)?(illustrations|images|icons)\//)
|
|
134
|
+
.match(/^\/?(?:(?:mono|colors)\/)?(illustrations|images|icons)\//)) === null || _a === void 0 ? void 0 : _a[1];
|
|
115
135
|
switch (colorType) {
|
|
116
136
|
case 'illustrations':
|
|
117
137
|
return 'illustrations';
|
|
@@ -121,18 +141,22 @@ function getColorType(relative) {
|
|
|
121
141
|
return 'images';
|
|
122
142
|
}
|
|
123
143
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
previous[group]
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}, {});
|
|
131
|
-
const pickBy = (list, getKey) => list.reduce((previous, currentItem) => {
|
|
132
|
-
const group = getKey(currentItem);
|
|
133
|
-
if (previous[group])
|
|
144
|
+
var groupBy = function (list, getKey) {
|
|
145
|
+
return list.reduce(function (previous, currentItem) {
|
|
146
|
+
var group = getKey(currentItem);
|
|
147
|
+
if (!previous[group])
|
|
148
|
+
previous[group] = [];
|
|
149
|
+
previous[group].push(currentItem);
|
|
134
150
|
return previous;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
151
|
+
}, {});
|
|
152
|
+
};
|
|
153
|
+
var pickBy = function (list, getKey) {
|
|
154
|
+
return list.reduce(function (previous, currentItem) {
|
|
155
|
+
var group = getKey(currentItem);
|
|
156
|
+
if (previous[group])
|
|
157
|
+
return previous;
|
|
158
|
+
previous[group] = currentItem;
|
|
159
|
+
return previous;
|
|
160
|
+
}, {});
|
|
161
|
+
};
|
|
138
162
|
//# sourceMappingURL=generateTs.js.map
|
package/lib/generateTs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateTs.js","sourceRoot":"","sources":["../src/generateTs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generateTs.js","sourceRoot":"","sources":["../src/generateTs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,gCAcC;AAxBD,yDAA6B;AAC7B,8CAAwB;AACxB,iCAAmD;AAQnD,SAAsB,UAAU;wDAC9B,QAAkB,EAClB,cAAyB,EACzB,SAAiB,EACjB,QAA4B;;QAA5B,yBAAA,EAAA,oBAA4B;;;;oBAEtB,IAAI,GAAG,YAAY,CAAC,QAAQ,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;oBACzD,iBAAiB,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;oBAEzC,qBAAM,kBAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,EAAA;;oBAA3C,SAA2C,CAAC;oBACtC,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;oBAClE,qBAAM,kBAAE,CAAC,SAAS,CAAC,eAAe,EAAE,iBAAiB,CAAC,EAAA;;oBAAtD,SAAsD,CAAC;oBAEvD,sBAAO,eAAe,EAAC;;;;CACxB;AAED,SAAS,QAAQ,CAAC,IAAU;IAC1B,OAAO,qGAGc,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,wYAsBlD,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,8CAA8C,CAAC,CAAC,CAAC,EAAE,eAC/D,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,6CAA6C,CAAC,CAAC,CAAC,EAAE,eAChE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,qDAAqD,CAAC,CAAC,CAAC,EAAE,eAE5E,IAAI,CAAC,YAAY;QACf,CAAC,CAAC,0DAA0D;QAC5D,CAAC,CAAC,EAAE,OAEP,CAAC;A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"__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
3
|
+
exports.setDebug = setDebug;
|
|
4
|
+
exports.log = log;
|
|
5
|
+
var isDebug = false;
|
|
5
6
|
function setDebug(active) {
|
|
6
7
|
isDebug = active;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
function log() {
|
|
10
|
+
var args = [];
|
|
11
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
12
|
+
args[_i] = arguments[_i];
|
|
13
|
+
}
|
|
10
14
|
if (!isDebug)
|
|
11
15
|
return;
|
|
12
|
-
return console.log(
|
|
16
|
+
return console.log.apply(console, args);
|
|
13
17
|
}
|
|
14
|
-
exports.log = log;
|
|
15
18
|
//# sourceMappingURL=logger.js.map
|
package/lib/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;AAEA,4BAEC;AAED,kBAGC;AATD,IAAI,OAAO,GAAG,KAAK,CAAC;AAEpB,SAAgB,QAAQ,CAAC,MAAe;IACtC,OAAO,GAAG,MAAM,CAAC;AACnB,CAAC;AAED,SAAgB,GAAG;IAAC,cAAc;SAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;QAAd,yBAAc;;IAChC,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,OAAO,OAAO,CAAC,GAAG,OAAX,OAAO,EAAQ,IAAI,EAAE;AAC9B,CAAC"}
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ThemeVariant } from '@atb-as/theme
|
|
1
|
+
import { ThemeVariant } from '@atb-as/theme';
|
|
2
2
|
export { ThemeVariant };
|
|
3
3
|
import normalizeToUnix from 'normalize-path';
|
|
4
|
-
export
|
|
4
|
+
export type AssetType = 'colors' | 'all' | 'mono';
|
|
5
5
|
export declare function themeVariantAsString(org: ThemeVariant): string;
|
|
6
6
|
export declare function stringAsThemeVariant(org: string): ThemeVariant;
|
|
7
7
|
export declare function fgNormalizedForUnix(path: string, options?: {
|
package/lib/utils.js
CHANGED
|
@@ -3,62 +3,62 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.normalizeToUnix = exports.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
exports.normalizeToUnix = exports.ThemeVariant = void 0;
|
|
7
|
+
exports.themeVariantAsString = themeVariantAsString;
|
|
8
|
+
exports.stringAsThemeVariant = stringAsThemeVariant;
|
|
9
|
+
exports.fgNormalizedForUnix = fgNormalizedForUnix;
|
|
10
|
+
var theme_1 = require("@atb-as/theme");
|
|
11
|
+
Object.defineProperty(exports, "ThemeVariant", { enumerable: true, get: function () { return theme_1.ThemeVariant; } });
|
|
12
|
+
var fast_glob_1 = __importDefault(require("fast-glob"));
|
|
13
|
+
var normalize_path_1 = __importDefault(require("normalize-path"));
|
|
11
14
|
exports.normalizeToUnix = normalize_path_1.default;
|
|
12
15
|
function themeVariantAsString(org) {
|
|
13
16
|
switch (org) {
|
|
14
|
-
case
|
|
17
|
+
case theme_1.ThemeVariant.Nfk:
|
|
15
18
|
return 'nfk';
|
|
16
|
-
case
|
|
19
|
+
case theme_1.ThemeVariant.AtB:
|
|
17
20
|
return 'atb';
|
|
18
|
-
case
|
|
21
|
+
case theme_1.ThemeVariant.FRAM:
|
|
19
22
|
return 'fram';
|
|
20
|
-
case
|
|
23
|
+
case theme_1.ThemeVariant.Troms:
|
|
21
24
|
return 'troms';
|
|
22
|
-
case
|
|
25
|
+
case theme_1.ThemeVariant.Innlandet:
|
|
23
26
|
return 'innlandet';
|
|
24
|
-
case
|
|
27
|
+
case theme_1.ThemeVariant.VKT:
|
|
25
28
|
return 'vkt';
|
|
26
|
-
case
|
|
29
|
+
case theme_1.ThemeVariant.Farte:
|
|
27
30
|
return 'farte';
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
|
-
exports.themeVariantAsString = themeVariantAsString;
|
|
31
33
|
function stringAsThemeVariant(org) {
|
|
32
34
|
switch (org) {
|
|
33
35
|
case 'nfk':
|
|
34
|
-
return
|
|
36
|
+
return theme_1.ThemeVariant.Nfk;
|
|
35
37
|
case 'atb':
|
|
36
|
-
return
|
|
38
|
+
return theme_1.ThemeVariant.AtB;
|
|
37
39
|
case 'fram':
|
|
38
|
-
return
|
|
40
|
+
return theme_1.ThemeVariant.FRAM;
|
|
39
41
|
case 'troms':
|
|
40
|
-
return
|
|
42
|
+
return theme_1.ThemeVariant.Troms;
|
|
41
43
|
case 'innlandet':
|
|
42
|
-
return
|
|
44
|
+
return theme_1.ThemeVariant.Innlandet;
|
|
43
45
|
case 'vkt':
|
|
44
|
-
return
|
|
46
|
+
return theme_1.ThemeVariant.VKT;
|
|
45
47
|
case 'farte':
|
|
46
|
-
return
|
|
48
|
+
return theme_1.ThemeVariant.Farte;
|
|
47
49
|
}
|
|
48
50
|
throw new Error('Invalid org');
|
|
49
51
|
}
|
|
50
|
-
exports.stringAsThemeVariant = stringAsThemeVariant;
|
|
51
52
|
// Due to globs nature forward UNIX type slashes should be used. Normalize paths.
|
|
52
53
|
// All paths returned are also UNIX style. All node functions normalize self, no
|
|
53
54
|
// need to do it manually.
|
|
54
55
|
// (see https://github.com/mrmlnc/fast-glob#how-to-write-patterns-on-windows)
|
|
55
56
|
function fgNormalizedForUnix(path, options) {
|
|
56
|
-
|
|
57
|
+
var opts = options && options.ignore
|
|
57
58
|
? {
|
|
58
|
-
ignore: options.ignore.map((f)
|
|
59
|
+
ignore: options.ignore.map(function (f) { return (0, normalize_path_1.default)(f); }),
|
|
59
60
|
}
|
|
60
61
|
: options;
|
|
61
62
|
return (0, fast_glob_1.default)((0, normalize_path_1.default)(path), opts);
|
|
62
63
|
}
|
|
63
|
-
exports.fgNormalizedForUnix = fgNormalizedForUnix;
|
|
64
64
|
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAQA,oDAiBC;AAED,oDAmBC;AAMD,kDAWC;AA/DD,uCAA2C;AAEnC,6FAFA,oBAAY,OAEA;AACpB,wDAA2B;AAC3B,kEAA6C;AA6DrC,0BA7DD,wBAAe,CA6DC;AAzDvB,SAAgB,oBAAoB,CAAC,GAAiB;IACpD,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,oBAAY,CAAC,GAAG;YACnB,OAAO,KAAK,CAAC;QACf,KAAK,oBAAY,CAAC,GAAG;YACnB,OAAO,KAAK,CAAC;QACf,KAAK,oBAAY,CAAC,IAAI;YACpB,OAAO,MAAM,CAAC;QAChB,KAAK,oBAAY,CAAC,KAAK;YACrB,OAAO,OAAO,CAAC;QACjB,KAAK,oBAAY,CAAC,SAAS;YACzB,OAAO,WAAW,CAAC;QACrB,KAAK,oBAAY,CAAC,GAAG;YACnB,OAAO,KAAK,CAAC;QACf,KAAK,oBAAY,CAAC,KAAK;YACrB,OAAO,OAAO,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAgB,oBAAoB,CAAC,GAAW;IAC9C,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,KAAK;YACR,OAAO,oBAAY,CAAC,GAAG,CAAC;QAC1B,KAAK,KAAK;YACR,OAAO,oBAAY,CAAC,GAAG,CAAC;QAC1B,KAAK,MAAM;YACT,OAAO,oBAAY,CAAC,IAAI,CAAC;QAC3B,KAAK,OAAO;YACV,OAAO,oBAAY,CAAC,KAAK,CAAC;QAC5B,KAAK,WAAW;YACd,OAAO,oBAAY,CAAC,SAAS,CAAC;QAChC,KAAK,KAAK;YACR,OAAO,oBAAY,CAAC,GAAG,CAAC;QAC1B,KAAK,OAAO;YACV,OAAO,oBAAY,CAAC,KAAK,CAAC;IAC9B,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;AACjC,CAAC;AAED,iFAAiF;AACjF,gFAAgF;AAChF,0BAA0B;AAC1B,6EAA6E;AAC7E,SAAgB,mBAAmB,CACjC,IAAY,EACZ,OAA4B;IAE5B,IAAM,IAAI,GACR,OAAO,IAAI,OAAO,CAAC,MAAM;QACvB,CAAC,CAAC;YACE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,IAAA,wBAAe,EAAC,CAAC,CAAC,EAAlB,CAAkB,CAAC;SACtD;QACH,CAAC,CAAC,OAAO,CAAC;IACd,OAAO,IAAA,mBAAE,EAAC,IAAA,wBAAe,EAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atb-as/generate-assets",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.2.0-rc.0",
|
|
4
4
|
"private": false,
|
|
5
|
+
"type": "commonjs",
|
|
5
6
|
"description": "OOS Design System generate-assets",
|
|
6
7
|
"license": "EUPL-1.2",
|
|
7
8
|
"bin": {
|
|
@@ -21,18 +22,18 @@
|
|
|
21
22
|
"@types/micromatch": "^4.0.2",
|
|
22
23
|
"@types/node": "^16.11.9",
|
|
23
24
|
"@types/normalize-path": "^3.0.0",
|
|
24
|
-
"typescript": "^
|
|
25
|
+
"typescript": "^5.1.6"
|
|
25
26
|
},
|
|
26
27
|
"publishConfig": {
|
|
27
28
|
"access": "public"
|
|
28
29
|
},
|
|
29
30
|
"dependencies": {
|
|
30
|
-
"@atb-as/theme": "^
|
|
31
|
+
"@atb-as/theme": "^11.0.0-rc.0",
|
|
31
32
|
"commander": "^9.4.0",
|
|
32
33
|
"fast-glob": "^3.2.11",
|
|
33
34
|
"micromatch": "^4.0.5",
|
|
34
35
|
"normalize-path": "^3.0.0",
|
|
35
36
|
"stream-editor": "^1.11.0"
|
|
36
37
|
},
|
|
37
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "b27fa3883fc58a07bfe6cc8c4873f81e231004ef"
|
|
38
39
|
}
|