@digdir/designsystemet 0.1.0-alpha.11 → 0.1.0-alpha.13
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/dist/bin/designsystemet.js +3445 -0
- package/dist/bin/designsystemet.js.map +1 -0
- package/dist/src/colors/colorUtils.js +364 -0
- package/dist/src/colors/colorUtils.js.map +1 -0
- package/dist/src/colors/index.js +607 -0
- package/dist/src/colors/index.js.map +1 -0
- package/dist/src/colors/themeUtils.js +365 -0
- package/dist/src/colors/themeUtils.js.map +1 -0
- package/dist/src/colors/types.js +1 -0
- package/dist/src/colors/types.js.map +1 -0
- package/dist/src/migrations/beta-to-v1.js +407 -0
- package/dist/src/migrations/beta-to-v1.js.map +1 -0
- package/dist/src/migrations/codemods/css/plugins.js +49 -0
- package/dist/src/migrations/codemods/css/plugins.js.map +1 -0
- package/dist/src/migrations/codemods/css/run.js +21 -0
- package/dist/src/migrations/codemods/css/run.js.map +1 -0
- package/dist/src/migrations/codemods/jsx/classname-prefix.js +65 -0
- package/dist/src/migrations/codemods/jsx/classname-prefix.js.map +1 -0
- package/dist/src/migrations/codemods/jsx/run.js +24 -0
- package/dist/src/migrations/codemods/jsx/run.js.map +1 -0
- package/dist/src/migrations/index.js +437 -0
- package/dist/src/migrations/index.js.map +1 -0
- package/dist/src/migrations/react-beta-to-v1.js +27 -0
- package/dist/src/migrations/react-beta-to-v1.js.map +1 -0
- package/dist/src/tokens/actions.js +2180 -0
- package/dist/src/tokens/actions.js.map +1 -0
- package/dist/src/tokens/build.js +2980 -0
- package/dist/src/tokens/build.js.map +1 -0
- package/dist/src/tokens/configs.js +2898 -0
- package/dist/src/tokens/configs.js.map +1 -0
- package/dist/src/tokens/formats/css.js +2656 -0
- package/dist/src/tokens/formats/css.js.map +1 -0
- package/dist/src/tokens/formats/js-tokens.js +44 -0
- package/dist/src/tokens/formats/js-tokens.js.map +1 -0
- package/dist/src/tokens/transformers.js +87 -0
- package/dist/src/tokens/transformers.js.map +1 -0
- package/dist/src/tokens/utils/noCase.js +30 -0
- package/dist/src/tokens/utils/noCase.js.map +1 -0
- package/dist/src/tokens/utils/permutateThemes.js +229 -0
- package/dist/src/tokens/utils/permutateThemes.js.map +1 -0
- package/dist/src/tokens/utils/utils.js +16 -0
- package/dist/src/tokens/utils/utils.js.map +1 -0
- package/package.json +23 -9
- package/dist/build/bin/designsystemet.js +0 -50
- package/dist/build/src/colors/colorUtils.js +0 -314
- package/dist/build/src/colors/index.js +0 -3
- package/dist/build/src/colors/themeUtils.js +0 -293
- package/dist/build/src/colors/types.js +0 -1
- package/dist/build/src/migrations/beta-to-v1.js +0 -341
- package/dist/build/src/migrations/codemods/css/plugins.js +0 -45
- package/dist/build/src/migrations/codemods/css/run.js +0 -17
- package/dist/build/src/migrations/codemods/jsx/classname-prefix.js +0 -80
- package/dist/build/src/migrations/codemods/jsx/run.js +0 -19
- package/dist/build/src/migrations/index.js +0 -6
- package/dist/build/src/migrations/react-beta-to-v1.js +0 -2
- package/dist/build/src/test/jsx-test.js +0 -10
- package/dist/build/src/tokens/actions.js +0 -20
- package/dist/build/src/tokens/build.js +0 -63
- package/dist/build/src/tokens/configs.js +0 -206
- package/dist/build/src/tokens/formats/css-classes.js +0 -78
- package/dist/build/src/tokens/formats/css-variables.js +0 -39
- package/dist/build/src/tokens/formats/js-tokens.js +0 -29
- package/dist/build/src/tokens/transformers.js +0 -42
- package/dist/build/src/tokens/utils/noCase.js +0 -30
- package/dist/build/src/tokens/utils/permutateThemes.js +0 -56
- package/dist/build/src/tokens/utils/utils.js +0 -21
- package/dist/build/tsconfig.tsbuildinfo +0 -1
- package/dist/types/bin/designsystemet.d.ts +0 -3
- package/dist/types/bin/designsystemet.d.ts.map +0 -1
- package/dist/types/src/colors/colorUtils.d.ts +0 -118
- package/dist/types/src/colors/colorUtils.d.ts.map +0 -1
- package/dist/types/src/colors/index.d.ts +0 -4
- package/dist/types/src/colors/index.d.ts.map +0 -1
- package/dist/types/src/colors/themeUtils.d.ts +0 -102
- package/dist/types/src/colors/themeUtils.d.ts.map +0 -1
- package/dist/types/src/colors/types.d.ts +0 -16
- package/dist/types/src/colors/types.d.ts.map +0 -1
- package/dist/types/src/migrations/beta-to-v1.d.ts +0 -3
- package/dist/types/src/migrations/beta-to-v1.d.ts.map +0 -1
- package/dist/types/src/migrations/codemods/css/plugins.d.ts +0 -6
- package/dist/types/src/migrations/codemods/css/plugins.d.ts.map +0 -1
- package/dist/types/src/migrations/codemods/css/run.d.ts +0 -8
- package/dist/types/src/migrations/codemods/css/run.d.ts.map +0 -1
- package/dist/types/src/migrations/codemods/jsx/classname-prefix.d.ts +0 -10
- package/dist/types/src/migrations/codemods/jsx/classname-prefix.d.ts.map +0 -1
- package/dist/types/src/migrations/codemods/jsx/run.d.ts +0 -7
- package/dist/types/src/migrations/codemods/jsx/run.d.ts.map +0 -1
- package/dist/types/src/migrations/index.d.ts +0 -6
- package/dist/types/src/migrations/index.d.ts.map +0 -1
- package/dist/types/src/migrations/react-beta-to-v1.d.ts +0 -3
- package/dist/types/src/migrations/react-beta-to-v1.d.ts.map +0 -1
- package/dist/types/src/test/jsx-test.d.ts +0 -4
- package/dist/types/src/test/jsx-test.d.ts.map +0 -1
- package/dist/types/src/tokens/actions.d.ts +0 -3
- package/dist/types/src/tokens/actions.d.ts.map +0 -1
- package/dist/types/src/tokens/build.d.ts +0 -11
- package/dist/types/src/tokens/build.d.ts.map +0 -1
- package/dist/types/src/tokens/configs.d.ts +0 -26
- package/dist/types/src/tokens/configs.d.ts.map +0 -1
- package/dist/types/src/tokens/formats/css-classes.d.ts +0 -6
- package/dist/types/src/tokens/formats/css-classes.d.ts.map +0 -1
- package/dist/types/src/tokens/formats/css-variables.d.ts +0 -3
- package/dist/types/src/tokens/formats/css-variables.d.ts.map +0 -1
- package/dist/types/src/tokens/formats/js-tokens.d.ts +0 -6
- package/dist/types/src/tokens/formats/js-tokens.d.ts.map +0 -1
- package/dist/types/src/tokens/transformers.d.ts +0 -5
- package/dist/types/src/tokens/transformers.d.ts.map +0 -1
- package/dist/types/src/tokens/utils/noCase.d.ts +0 -11
- package/dist/types/src/tokens/utils/noCase.d.ts.map +0 -1
- package/dist/types/src/tokens/utils/permutateThemes.d.ts +0 -7
- package/dist/types/src/tokens/utils/permutateThemes.d.ts.map +0 -1
- package/dist/types/src/tokens/utils/utils.d.ts +0 -17
- package/dist/types/src/tokens/utils/utils.d.ts.map +0 -1
|
@@ -0,0 +1,3445 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
10
|
+
}) : x)(function(x) {
|
|
11
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
+
});
|
|
14
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
+
};
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name in all)
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
|
|
38
|
+
// ../../node_modules/universalify/index.js
|
|
39
|
+
var require_universalify = __commonJS({
|
|
40
|
+
"../../node_modules/universalify/index.js"(exports) {
|
|
41
|
+
"use strict";
|
|
42
|
+
exports.fromCallback = function(fn) {
|
|
43
|
+
return Object.defineProperty(function(...args) {
|
|
44
|
+
if (typeof args[args.length - 1] === "function") fn.apply(this, args);
|
|
45
|
+
else {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
fn.call(
|
|
48
|
+
this,
|
|
49
|
+
...args,
|
|
50
|
+
(err, res) => err != null ? reject(err) : resolve(res)
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}, "name", { value: fn.name });
|
|
55
|
+
};
|
|
56
|
+
exports.fromPromise = function(fn) {
|
|
57
|
+
return Object.defineProperty(function(...args) {
|
|
58
|
+
const cb = args[args.length - 1];
|
|
59
|
+
if (typeof cb !== "function") return fn.apply(this, args);
|
|
60
|
+
else fn.apply(this, args.slice(0, -1)).then((r) => cb(null, r), cb);
|
|
61
|
+
}, "name", { value: fn.name });
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// ../../node_modules/graceful-fs/polyfills.js
|
|
67
|
+
var require_polyfills = __commonJS({
|
|
68
|
+
"../../node_modules/graceful-fs/polyfills.js"(exports, module) {
|
|
69
|
+
"use strict";
|
|
70
|
+
var constants = __require("constants");
|
|
71
|
+
var origCwd = process.cwd;
|
|
72
|
+
var cwd = null;
|
|
73
|
+
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
|
|
74
|
+
process.cwd = function() {
|
|
75
|
+
if (!cwd)
|
|
76
|
+
cwd = origCwd.call(process);
|
|
77
|
+
return cwd;
|
|
78
|
+
};
|
|
79
|
+
try {
|
|
80
|
+
process.cwd();
|
|
81
|
+
} catch (er) {
|
|
82
|
+
}
|
|
83
|
+
if (typeof process.chdir === "function") {
|
|
84
|
+
chdir = process.chdir;
|
|
85
|
+
process.chdir = function(d) {
|
|
86
|
+
cwd = null;
|
|
87
|
+
chdir.call(process, d);
|
|
88
|
+
};
|
|
89
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
|
|
90
|
+
}
|
|
91
|
+
var chdir;
|
|
92
|
+
module.exports = patch;
|
|
93
|
+
function patch(fs4) {
|
|
94
|
+
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
95
|
+
patchLchmod(fs4);
|
|
96
|
+
}
|
|
97
|
+
if (!fs4.lutimes) {
|
|
98
|
+
patchLutimes(fs4);
|
|
99
|
+
}
|
|
100
|
+
fs4.chown = chownFix(fs4.chown);
|
|
101
|
+
fs4.fchown = chownFix(fs4.fchown);
|
|
102
|
+
fs4.lchown = chownFix(fs4.lchown);
|
|
103
|
+
fs4.chmod = chmodFix(fs4.chmod);
|
|
104
|
+
fs4.fchmod = chmodFix(fs4.fchmod);
|
|
105
|
+
fs4.lchmod = chmodFix(fs4.lchmod);
|
|
106
|
+
fs4.chownSync = chownFixSync(fs4.chownSync);
|
|
107
|
+
fs4.fchownSync = chownFixSync(fs4.fchownSync);
|
|
108
|
+
fs4.lchownSync = chownFixSync(fs4.lchownSync);
|
|
109
|
+
fs4.chmodSync = chmodFixSync(fs4.chmodSync);
|
|
110
|
+
fs4.fchmodSync = chmodFixSync(fs4.fchmodSync);
|
|
111
|
+
fs4.lchmodSync = chmodFixSync(fs4.lchmodSync);
|
|
112
|
+
fs4.stat = statFix(fs4.stat);
|
|
113
|
+
fs4.fstat = statFix(fs4.fstat);
|
|
114
|
+
fs4.lstat = statFix(fs4.lstat);
|
|
115
|
+
fs4.statSync = statFixSync(fs4.statSync);
|
|
116
|
+
fs4.fstatSync = statFixSync(fs4.fstatSync);
|
|
117
|
+
fs4.lstatSync = statFixSync(fs4.lstatSync);
|
|
118
|
+
if (fs4.chmod && !fs4.lchmod) {
|
|
119
|
+
fs4.lchmod = function(path2, mode, cb) {
|
|
120
|
+
if (cb) process.nextTick(cb);
|
|
121
|
+
};
|
|
122
|
+
fs4.lchmodSync = function() {
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
if (fs4.chown && !fs4.lchown) {
|
|
126
|
+
fs4.lchown = function(path2, uid, gid, cb) {
|
|
127
|
+
if (cb) process.nextTick(cb);
|
|
128
|
+
};
|
|
129
|
+
fs4.lchownSync = function() {
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
if (platform === "win32") {
|
|
133
|
+
fs4.rename = typeof fs4.rename !== "function" ? fs4.rename : function(fs$rename) {
|
|
134
|
+
function rename(from, to, cb) {
|
|
135
|
+
var start = Date.now();
|
|
136
|
+
var backoff = 0;
|
|
137
|
+
fs$rename(from, to, function CB(er) {
|
|
138
|
+
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
|
|
139
|
+
setTimeout(function() {
|
|
140
|
+
fs4.stat(to, function(stater, st) {
|
|
141
|
+
if (stater && stater.code === "ENOENT")
|
|
142
|
+
fs$rename(from, to, CB);
|
|
143
|
+
else
|
|
144
|
+
cb(er);
|
|
145
|
+
});
|
|
146
|
+
}, backoff);
|
|
147
|
+
if (backoff < 100)
|
|
148
|
+
backoff += 10;
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (cb) cb(er);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
|
|
155
|
+
return rename;
|
|
156
|
+
}(fs4.rename);
|
|
157
|
+
}
|
|
158
|
+
fs4.read = typeof fs4.read !== "function" ? fs4.read : function(fs$read) {
|
|
159
|
+
function read(fd, buffer, offset, length, position, callback_) {
|
|
160
|
+
var callback;
|
|
161
|
+
if (callback_ && typeof callback_ === "function") {
|
|
162
|
+
var eagCounter = 0;
|
|
163
|
+
callback = function(er, _, __) {
|
|
164
|
+
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
165
|
+
eagCounter++;
|
|
166
|
+
return fs$read.call(fs4, fd, buffer, offset, length, position, callback);
|
|
167
|
+
}
|
|
168
|
+
callback_.apply(this, arguments);
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
return fs$read.call(fs4, fd, buffer, offset, length, position, callback);
|
|
172
|
+
}
|
|
173
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
|
|
174
|
+
return read;
|
|
175
|
+
}(fs4.read);
|
|
176
|
+
fs4.readSync = typeof fs4.readSync !== "function" ? fs4.readSync : /* @__PURE__ */ function(fs$readSync) {
|
|
177
|
+
return function(fd, buffer, offset, length, position) {
|
|
178
|
+
var eagCounter = 0;
|
|
179
|
+
while (true) {
|
|
180
|
+
try {
|
|
181
|
+
return fs$readSync.call(fs4, fd, buffer, offset, length, position);
|
|
182
|
+
} catch (er) {
|
|
183
|
+
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
184
|
+
eagCounter++;
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
throw er;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
}(fs4.readSync);
|
|
192
|
+
function patchLchmod(fs5) {
|
|
193
|
+
fs5.lchmod = function(path2, mode, callback) {
|
|
194
|
+
fs5.open(
|
|
195
|
+
path2,
|
|
196
|
+
constants.O_WRONLY | constants.O_SYMLINK,
|
|
197
|
+
mode,
|
|
198
|
+
function(err, fd) {
|
|
199
|
+
if (err) {
|
|
200
|
+
if (callback) callback(err);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
fs5.fchmod(fd, mode, function(err2) {
|
|
204
|
+
fs5.close(fd, function(err22) {
|
|
205
|
+
if (callback) callback(err2 || err22);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
};
|
|
211
|
+
fs5.lchmodSync = function(path2, mode) {
|
|
212
|
+
var fd = fs5.openSync(path2, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
213
|
+
var threw = true;
|
|
214
|
+
var ret;
|
|
215
|
+
try {
|
|
216
|
+
ret = fs5.fchmodSync(fd, mode);
|
|
217
|
+
threw = false;
|
|
218
|
+
} finally {
|
|
219
|
+
if (threw) {
|
|
220
|
+
try {
|
|
221
|
+
fs5.closeSync(fd);
|
|
222
|
+
} catch (er) {
|
|
223
|
+
}
|
|
224
|
+
} else {
|
|
225
|
+
fs5.closeSync(fd);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return ret;
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
function patchLutimes(fs5) {
|
|
232
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs5.futimes) {
|
|
233
|
+
fs5.lutimes = function(path2, at, mt, cb) {
|
|
234
|
+
fs5.open(path2, constants.O_SYMLINK, function(er, fd) {
|
|
235
|
+
if (er) {
|
|
236
|
+
if (cb) cb(er);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
fs5.futimes(fd, at, mt, function(er2) {
|
|
240
|
+
fs5.close(fd, function(er22) {
|
|
241
|
+
if (cb) cb(er2 || er22);
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
fs5.lutimesSync = function(path2, at, mt) {
|
|
247
|
+
var fd = fs5.openSync(path2, constants.O_SYMLINK);
|
|
248
|
+
var ret;
|
|
249
|
+
var threw = true;
|
|
250
|
+
try {
|
|
251
|
+
ret = fs5.futimesSync(fd, at, mt);
|
|
252
|
+
threw = false;
|
|
253
|
+
} finally {
|
|
254
|
+
if (threw) {
|
|
255
|
+
try {
|
|
256
|
+
fs5.closeSync(fd);
|
|
257
|
+
} catch (er) {
|
|
258
|
+
}
|
|
259
|
+
} else {
|
|
260
|
+
fs5.closeSync(fd);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return ret;
|
|
264
|
+
};
|
|
265
|
+
} else if (fs5.futimes) {
|
|
266
|
+
fs5.lutimes = function(_a, _b, _c, cb) {
|
|
267
|
+
if (cb) process.nextTick(cb);
|
|
268
|
+
};
|
|
269
|
+
fs5.lutimesSync = function() {
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
function chmodFix(orig) {
|
|
274
|
+
if (!orig) return orig;
|
|
275
|
+
return function(target, mode, cb) {
|
|
276
|
+
return orig.call(fs4, target, mode, function(er) {
|
|
277
|
+
if (chownErOk(er)) er = null;
|
|
278
|
+
if (cb) cb.apply(this, arguments);
|
|
279
|
+
});
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function chmodFixSync(orig) {
|
|
283
|
+
if (!orig) return orig;
|
|
284
|
+
return function(target, mode) {
|
|
285
|
+
try {
|
|
286
|
+
return orig.call(fs4, target, mode);
|
|
287
|
+
} catch (er) {
|
|
288
|
+
if (!chownErOk(er)) throw er;
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
function chownFix(orig) {
|
|
293
|
+
if (!orig) return orig;
|
|
294
|
+
return function(target, uid, gid, cb) {
|
|
295
|
+
return orig.call(fs4, target, uid, gid, function(er) {
|
|
296
|
+
if (chownErOk(er)) er = null;
|
|
297
|
+
if (cb) cb.apply(this, arguments);
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
function chownFixSync(orig) {
|
|
302
|
+
if (!orig) return orig;
|
|
303
|
+
return function(target, uid, gid) {
|
|
304
|
+
try {
|
|
305
|
+
return orig.call(fs4, target, uid, gid);
|
|
306
|
+
} catch (er) {
|
|
307
|
+
if (!chownErOk(er)) throw er;
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
function statFix(orig) {
|
|
312
|
+
if (!orig) return orig;
|
|
313
|
+
return function(target, options, cb) {
|
|
314
|
+
if (typeof options === "function") {
|
|
315
|
+
cb = options;
|
|
316
|
+
options = null;
|
|
317
|
+
}
|
|
318
|
+
function callback(er, stats) {
|
|
319
|
+
if (stats) {
|
|
320
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
321
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
322
|
+
}
|
|
323
|
+
if (cb) cb.apply(this, arguments);
|
|
324
|
+
}
|
|
325
|
+
return options ? orig.call(fs4, target, options, callback) : orig.call(fs4, target, callback);
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function statFixSync(orig) {
|
|
329
|
+
if (!orig) return orig;
|
|
330
|
+
return function(target, options) {
|
|
331
|
+
var stats = options ? orig.call(fs4, target, options) : orig.call(fs4, target);
|
|
332
|
+
if (stats) {
|
|
333
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
334
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
335
|
+
}
|
|
336
|
+
return stats;
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function chownErOk(er) {
|
|
340
|
+
if (!er)
|
|
341
|
+
return true;
|
|
342
|
+
if (er.code === "ENOSYS")
|
|
343
|
+
return true;
|
|
344
|
+
var nonroot = !process.getuid || process.getuid() !== 0;
|
|
345
|
+
if (nonroot) {
|
|
346
|
+
if (er.code === "EINVAL" || er.code === "EPERM")
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
// ../../node_modules/graceful-fs/legacy-streams.js
|
|
356
|
+
var require_legacy_streams = __commonJS({
|
|
357
|
+
"../../node_modules/graceful-fs/legacy-streams.js"(exports, module) {
|
|
358
|
+
"use strict";
|
|
359
|
+
var Stream = __require("stream").Stream;
|
|
360
|
+
module.exports = legacy;
|
|
361
|
+
function legacy(fs4) {
|
|
362
|
+
return {
|
|
363
|
+
ReadStream,
|
|
364
|
+
WriteStream
|
|
365
|
+
};
|
|
366
|
+
function ReadStream(path2, options) {
|
|
367
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path2, options);
|
|
368
|
+
Stream.call(this);
|
|
369
|
+
var self = this;
|
|
370
|
+
this.path = path2;
|
|
371
|
+
this.fd = null;
|
|
372
|
+
this.readable = true;
|
|
373
|
+
this.paused = false;
|
|
374
|
+
this.flags = "r";
|
|
375
|
+
this.mode = 438;
|
|
376
|
+
this.bufferSize = 64 * 1024;
|
|
377
|
+
options = options || {};
|
|
378
|
+
var keys = Object.keys(options);
|
|
379
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
380
|
+
var key = keys[index];
|
|
381
|
+
this[key] = options[key];
|
|
382
|
+
}
|
|
383
|
+
if (this.encoding) this.setEncoding(this.encoding);
|
|
384
|
+
if (this.start !== void 0) {
|
|
385
|
+
if ("number" !== typeof this.start) {
|
|
386
|
+
throw TypeError("start must be a Number");
|
|
387
|
+
}
|
|
388
|
+
if (this.end === void 0) {
|
|
389
|
+
this.end = Infinity;
|
|
390
|
+
} else if ("number" !== typeof this.end) {
|
|
391
|
+
throw TypeError("end must be a Number");
|
|
392
|
+
}
|
|
393
|
+
if (this.start > this.end) {
|
|
394
|
+
throw new Error("start must be <= end");
|
|
395
|
+
}
|
|
396
|
+
this.pos = this.start;
|
|
397
|
+
}
|
|
398
|
+
if (this.fd !== null) {
|
|
399
|
+
process.nextTick(function() {
|
|
400
|
+
self._read();
|
|
401
|
+
});
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
fs4.open(this.path, this.flags, this.mode, function(err, fd) {
|
|
405
|
+
if (err) {
|
|
406
|
+
self.emit("error", err);
|
|
407
|
+
self.readable = false;
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
self.fd = fd;
|
|
411
|
+
self.emit("open", fd);
|
|
412
|
+
self._read();
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
function WriteStream(path2, options) {
|
|
416
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path2, options);
|
|
417
|
+
Stream.call(this);
|
|
418
|
+
this.path = path2;
|
|
419
|
+
this.fd = null;
|
|
420
|
+
this.writable = true;
|
|
421
|
+
this.flags = "w";
|
|
422
|
+
this.encoding = "binary";
|
|
423
|
+
this.mode = 438;
|
|
424
|
+
this.bytesWritten = 0;
|
|
425
|
+
options = options || {};
|
|
426
|
+
var keys = Object.keys(options);
|
|
427
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
428
|
+
var key = keys[index];
|
|
429
|
+
this[key] = options[key];
|
|
430
|
+
}
|
|
431
|
+
if (this.start !== void 0) {
|
|
432
|
+
if ("number" !== typeof this.start) {
|
|
433
|
+
throw TypeError("start must be a Number");
|
|
434
|
+
}
|
|
435
|
+
if (this.start < 0) {
|
|
436
|
+
throw new Error("start must be >= zero");
|
|
437
|
+
}
|
|
438
|
+
this.pos = this.start;
|
|
439
|
+
}
|
|
440
|
+
this.busy = false;
|
|
441
|
+
this._queue = [];
|
|
442
|
+
if (this.fd === null) {
|
|
443
|
+
this._open = fs4.open;
|
|
444
|
+
this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
|
|
445
|
+
this.flush();
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
// ../../node_modules/graceful-fs/clone.js
|
|
453
|
+
var require_clone = __commonJS({
|
|
454
|
+
"../../node_modules/graceful-fs/clone.js"(exports, module) {
|
|
455
|
+
"use strict";
|
|
456
|
+
module.exports = clone;
|
|
457
|
+
var getPrototypeOf = Object.getPrototypeOf || function(obj) {
|
|
458
|
+
return obj.__proto__;
|
|
459
|
+
};
|
|
460
|
+
function clone(obj) {
|
|
461
|
+
if (obj === null || typeof obj !== "object")
|
|
462
|
+
return obj;
|
|
463
|
+
if (obj instanceof Object)
|
|
464
|
+
var copy = { __proto__: getPrototypeOf(obj) };
|
|
465
|
+
else
|
|
466
|
+
var copy = /* @__PURE__ */ Object.create(null);
|
|
467
|
+
Object.getOwnPropertyNames(obj).forEach(function(key) {
|
|
468
|
+
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
|
|
469
|
+
});
|
|
470
|
+
return copy;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
// ../../node_modules/graceful-fs/graceful-fs.js
|
|
476
|
+
var require_graceful_fs = __commonJS({
|
|
477
|
+
"../../node_modules/graceful-fs/graceful-fs.js"(exports, module) {
|
|
478
|
+
"use strict";
|
|
479
|
+
var fs4 = __require("fs");
|
|
480
|
+
var polyfills = require_polyfills();
|
|
481
|
+
var legacy = require_legacy_streams();
|
|
482
|
+
var clone = require_clone();
|
|
483
|
+
var util = __require("util");
|
|
484
|
+
var gracefulQueue;
|
|
485
|
+
var previousSymbol;
|
|
486
|
+
if (typeof Symbol === "function" && typeof Symbol.for === "function") {
|
|
487
|
+
gracefulQueue = Symbol.for("graceful-fs.queue");
|
|
488
|
+
previousSymbol = Symbol.for("graceful-fs.previous");
|
|
489
|
+
} else {
|
|
490
|
+
gracefulQueue = "___graceful-fs.queue";
|
|
491
|
+
previousSymbol = "___graceful-fs.previous";
|
|
492
|
+
}
|
|
493
|
+
function noop() {
|
|
494
|
+
}
|
|
495
|
+
function publishQueue(context, queue2) {
|
|
496
|
+
Object.defineProperty(context, gracefulQueue, {
|
|
497
|
+
get: function() {
|
|
498
|
+
return queue2;
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
var debug = noop;
|
|
503
|
+
if (util.debuglog)
|
|
504
|
+
debug = util.debuglog("gfs4");
|
|
505
|
+
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
|
|
506
|
+
debug = function() {
|
|
507
|
+
var m = util.format.apply(util, arguments);
|
|
508
|
+
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
|
509
|
+
console.error(m);
|
|
510
|
+
};
|
|
511
|
+
if (!fs4[gracefulQueue]) {
|
|
512
|
+
queue = global[gracefulQueue] || [];
|
|
513
|
+
publishQueue(fs4, queue);
|
|
514
|
+
fs4.close = function(fs$close) {
|
|
515
|
+
function close(fd, cb) {
|
|
516
|
+
return fs$close.call(fs4, fd, function(err) {
|
|
517
|
+
if (!err) {
|
|
518
|
+
resetQueue();
|
|
519
|
+
}
|
|
520
|
+
if (typeof cb === "function")
|
|
521
|
+
cb.apply(this, arguments);
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
Object.defineProperty(close, previousSymbol, {
|
|
525
|
+
value: fs$close
|
|
526
|
+
});
|
|
527
|
+
return close;
|
|
528
|
+
}(fs4.close);
|
|
529
|
+
fs4.closeSync = function(fs$closeSync) {
|
|
530
|
+
function closeSync(fd) {
|
|
531
|
+
fs$closeSync.apply(fs4, arguments);
|
|
532
|
+
resetQueue();
|
|
533
|
+
}
|
|
534
|
+
Object.defineProperty(closeSync, previousSymbol, {
|
|
535
|
+
value: fs$closeSync
|
|
536
|
+
});
|
|
537
|
+
return closeSync;
|
|
538
|
+
}(fs4.closeSync);
|
|
539
|
+
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
540
|
+
process.on("exit", function() {
|
|
541
|
+
debug(fs4[gracefulQueue]);
|
|
542
|
+
__require("assert").equal(fs4[gracefulQueue].length, 0);
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
var queue;
|
|
547
|
+
if (!global[gracefulQueue]) {
|
|
548
|
+
publishQueue(global, fs4[gracefulQueue]);
|
|
549
|
+
}
|
|
550
|
+
module.exports = patch(clone(fs4));
|
|
551
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs4.__patched) {
|
|
552
|
+
module.exports = patch(fs4);
|
|
553
|
+
fs4.__patched = true;
|
|
554
|
+
}
|
|
555
|
+
function patch(fs5) {
|
|
556
|
+
polyfills(fs5);
|
|
557
|
+
fs5.gracefulify = patch;
|
|
558
|
+
fs5.createReadStream = createReadStream;
|
|
559
|
+
fs5.createWriteStream = createWriteStream;
|
|
560
|
+
var fs$readFile = fs5.readFile;
|
|
561
|
+
fs5.readFile = readFile;
|
|
562
|
+
function readFile(path2, options, cb) {
|
|
563
|
+
if (typeof options === "function")
|
|
564
|
+
cb = options, options = null;
|
|
565
|
+
return go$readFile(path2, options, cb);
|
|
566
|
+
function go$readFile(path3, options2, cb2, startTime) {
|
|
567
|
+
return fs$readFile(path3, options2, function(err) {
|
|
568
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
569
|
+
enqueue([go$readFile, [path3, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
570
|
+
else {
|
|
571
|
+
if (typeof cb2 === "function")
|
|
572
|
+
cb2.apply(this, arguments);
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
var fs$writeFile = fs5.writeFile;
|
|
578
|
+
fs5.writeFile = writeFile;
|
|
579
|
+
function writeFile(path2, data, options, cb) {
|
|
580
|
+
if (typeof options === "function")
|
|
581
|
+
cb = options, options = null;
|
|
582
|
+
return go$writeFile(path2, data, options, cb);
|
|
583
|
+
function go$writeFile(path3, data2, options2, cb2, startTime) {
|
|
584
|
+
return fs$writeFile(path3, data2, options2, function(err) {
|
|
585
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
586
|
+
enqueue([go$writeFile, [path3, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
587
|
+
else {
|
|
588
|
+
if (typeof cb2 === "function")
|
|
589
|
+
cb2.apply(this, arguments);
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
var fs$appendFile = fs5.appendFile;
|
|
595
|
+
if (fs$appendFile)
|
|
596
|
+
fs5.appendFile = appendFile;
|
|
597
|
+
function appendFile(path2, data, options, cb) {
|
|
598
|
+
if (typeof options === "function")
|
|
599
|
+
cb = options, options = null;
|
|
600
|
+
return go$appendFile(path2, data, options, cb);
|
|
601
|
+
function go$appendFile(path3, data2, options2, cb2, startTime) {
|
|
602
|
+
return fs$appendFile(path3, data2, options2, function(err) {
|
|
603
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
604
|
+
enqueue([go$appendFile, [path3, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
605
|
+
else {
|
|
606
|
+
if (typeof cb2 === "function")
|
|
607
|
+
cb2.apply(this, arguments);
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
var fs$copyFile = fs5.copyFile;
|
|
613
|
+
if (fs$copyFile)
|
|
614
|
+
fs5.copyFile = copyFile;
|
|
615
|
+
function copyFile(src, dest, flags, cb) {
|
|
616
|
+
if (typeof flags === "function") {
|
|
617
|
+
cb = flags;
|
|
618
|
+
flags = 0;
|
|
619
|
+
}
|
|
620
|
+
return go$copyFile(src, dest, flags, cb);
|
|
621
|
+
function go$copyFile(src2, dest2, flags2, cb2, startTime) {
|
|
622
|
+
return fs$copyFile(src2, dest2, flags2, function(err) {
|
|
623
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
624
|
+
enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
625
|
+
else {
|
|
626
|
+
if (typeof cb2 === "function")
|
|
627
|
+
cb2.apply(this, arguments);
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
var fs$readdir = fs5.readdir;
|
|
633
|
+
fs5.readdir = readdir;
|
|
634
|
+
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
635
|
+
function readdir(path2, options, cb) {
|
|
636
|
+
if (typeof options === "function")
|
|
637
|
+
cb = options, options = null;
|
|
638
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path3, options2, cb2, startTime) {
|
|
639
|
+
return fs$readdir(path3, fs$readdirCallback(
|
|
640
|
+
path3,
|
|
641
|
+
options2,
|
|
642
|
+
cb2,
|
|
643
|
+
startTime
|
|
644
|
+
));
|
|
645
|
+
} : function go$readdir2(path3, options2, cb2, startTime) {
|
|
646
|
+
return fs$readdir(path3, options2, fs$readdirCallback(
|
|
647
|
+
path3,
|
|
648
|
+
options2,
|
|
649
|
+
cb2,
|
|
650
|
+
startTime
|
|
651
|
+
));
|
|
652
|
+
};
|
|
653
|
+
return go$readdir(path2, options, cb);
|
|
654
|
+
function fs$readdirCallback(path3, options2, cb2, startTime) {
|
|
655
|
+
return function(err, files) {
|
|
656
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
657
|
+
enqueue([
|
|
658
|
+
go$readdir,
|
|
659
|
+
[path3, options2, cb2],
|
|
660
|
+
err,
|
|
661
|
+
startTime || Date.now(),
|
|
662
|
+
Date.now()
|
|
663
|
+
]);
|
|
664
|
+
else {
|
|
665
|
+
if (files && files.sort)
|
|
666
|
+
files.sort();
|
|
667
|
+
if (typeof cb2 === "function")
|
|
668
|
+
cb2.call(this, err, files);
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
if (process.version.substr(0, 4) === "v0.8") {
|
|
674
|
+
var legStreams = legacy(fs5);
|
|
675
|
+
ReadStream = legStreams.ReadStream;
|
|
676
|
+
WriteStream = legStreams.WriteStream;
|
|
677
|
+
}
|
|
678
|
+
var fs$ReadStream = fs5.ReadStream;
|
|
679
|
+
if (fs$ReadStream) {
|
|
680
|
+
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
681
|
+
ReadStream.prototype.open = ReadStream$open;
|
|
682
|
+
}
|
|
683
|
+
var fs$WriteStream = fs5.WriteStream;
|
|
684
|
+
if (fs$WriteStream) {
|
|
685
|
+
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
686
|
+
WriteStream.prototype.open = WriteStream$open;
|
|
687
|
+
}
|
|
688
|
+
Object.defineProperty(fs5, "ReadStream", {
|
|
689
|
+
get: function() {
|
|
690
|
+
return ReadStream;
|
|
691
|
+
},
|
|
692
|
+
set: function(val) {
|
|
693
|
+
ReadStream = val;
|
|
694
|
+
},
|
|
695
|
+
enumerable: true,
|
|
696
|
+
configurable: true
|
|
697
|
+
});
|
|
698
|
+
Object.defineProperty(fs5, "WriteStream", {
|
|
699
|
+
get: function() {
|
|
700
|
+
return WriteStream;
|
|
701
|
+
},
|
|
702
|
+
set: function(val) {
|
|
703
|
+
WriteStream = val;
|
|
704
|
+
},
|
|
705
|
+
enumerable: true,
|
|
706
|
+
configurable: true
|
|
707
|
+
});
|
|
708
|
+
var FileReadStream = ReadStream;
|
|
709
|
+
Object.defineProperty(fs5, "FileReadStream", {
|
|
710
|
+
get: function() {
|
|
711
|
+
return FileReadStream;
|
|
712
|
+
},
|
|
713
|
+
set: function(val) {
|
|
714
|
+
FileReadStream = val;
|
|
715
|
+
},
|
|
716
|
+
enumerable: true,
|
|
717
|
+
configurable: true
|
|
718
|
+
});
|
|
719
|
+
var FileWriteStream = WriteStream;
|
|
720
|
+
Object.defineProperty(fs5, "FileWriteStream", {
|
|
721
|
+
get: function() {
|
|
722
|
+
return FileWriteStream;
|
|
723
|
+
},
|
|
724
|
+
set: function(val) {
|
|
725
|
+
FileWriteStream = val;
|
|
726
|
+
},
|
|
727
|
+
enumerable: true,
|
|
728
|
+
configurable: true
|
|
729
|
+
});
|
|
730
|
+
function ReadStream(path2, options) {
|
|
731
|
+
if (this instanceof ReadStream)
|
|
732
|
+
return fs$ReadStream.apply(this, arguments), this;
|
|
733
|
+
else
|
|
734
|
+
return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
|
|
735
|
+
}
|
|
736
|
+
function ReadStream$open() {
|
|
737
|
+
var that = this;
|
|
738
|
+
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
739
|
+
if (err) {
|
|
740
|
+
if (that.autoClose)
|
|
741
|
+
that.destroy();
|
|
742
|
+
that.emit("error", err);
|
|
743
|
+
} else {
|
|
744
|
+
that.fd = fd;
|
|
745
|
+
that.emit("open", fd);
|
|
746
|
+
that.read();
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
function WriteStream(path2, options) {
|
|
751
|
+
if (this instanceof WriteStream)
|
|
752
|
+
return fs$WriteStream.apply(this, arguments), this;
|
|
753
|
+
else
|
|
754
|
+
return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
|
|
755
|
+
}
|
|
756
|
+
function WriteStream$open() {
|
|
757
|
+
var that = this;
|
|
758
|
+
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
759
|
+
if (err) {
|
|
760
|
+
that.destroy();
|
|
761
|
+
that.emit("error", err);
|
|
762
|
+
} else {
|
|
763
|
+
that.fd = fd;
|
|
764
|
+
that.emit("open", fd);
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
function createReadStream(path2, options) {
|
|
769
|
+
return new fs5.ReadStream(path2, options);
|
|
770
|
+
}
|
|
771
|
+
function createWriteStream(path2, options) {
|
|
772
|
+
return new fs5.WriteStream(path2, options);
|
|
773
|
+
}
|
|
774
|
+
var fs$open = fs5.open;
|
|
775
|
+
fs5.open = open;
|
|
776
|
+
function open(path2, flags, mode, cb) {
|
|
777
|
+
if (typeof mode === "function")
|
|
778
|
+
cb = mode, mode = null;
|
|
779
|
+
return go$open(path2, flags, mode, cb);
|
|
780
|
+
function go$open(path3, flags2, mode2, cb2, startTime) {
|
|
781
|
+
return fs$open(path3, flags2, mode2, function(err, fd) {
|
|
782
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
783
|
+
enqueue([go$open, [path3, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
784
|
+
else {
|
|
785
|
+
if (typeof cb2 === "function")
|
|
786
|
+
cb2.apply(this, arguments);
|
|
787
|
+
}
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
return fs5;
|
|
792
|
+
}
|
|
793
|
+
function enqueue(elem) {
|
|
794
|
+
debug("ENQUEUE", elem[0].name, elem[1]);
|
|
795
|
+
fs4[gracefulQueue].push(elem);
|
|
796
|
+
retry();
|
|
797
|
+
}
|
|
798
|
+
var retryTimer;
|
|
799
|
+
function resetQueue() {
|
|
800
|
+
var now = Date.now();
|
|
801
|
+
for (var i = 0; i < fs4[gracefulQueue].length; ++i) {
|
|
802
|
+
if (fs4[gracefulQueue][i].length > 2) {
|
|
803
|
+
fs4[gracefulQueue][i][3] = now;
|
|
804
|
+
fs4[gracefulQueue][i][4] = now;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
retry();
|
|
808
|
+
}
|
|
809
|
+
function retry() {
|
|
810
|
+
clearTimeout(retryTimer);
|
|
811
|
+
retryTimer = void 0;
|
|
812
|
+
if (fs4[gracefulQueue].length === 0)
|
|
813
|
+
return;
|
|
814
|
+
var elem = fs4[gracefulQueue].shift();
|
|
815
|
+
var fn = elem[0];
|
|
816
|
+
var args = elem[1];
|
|
817
|
+
var err = elem[2];
|
|
818
|
+
var startTime = elem[3];
|
|
819
|
+
var lastTime = elem[4];
|
|
820
|
+
if (startTime === void 0) {
|
|
821
|
+
debug("RETRY", fn.name, args);
|
|
822
|
+
fn.apply(null, args);
|
|
823
|
+
} else if (Date.now() - startTime >= 6e4) {
|
|
824
|
+
debug("TIMEOUT", fn.name, args);
|
|
825
|
+
var cb = args.pop();
|
|
826
|
+
if (typeof cb === "function")
|
|
827
|
+
cb.call(null, err);
|
|
828
|
+
} else {
|
|
829
|
+
var sinceAttempt = Date.now() - lastTime;
|
|
830
|
+
var sinceStart = Math.max(lastTime - startTime, 1);
|
|
831
|
+
var desiredDelay = Math.min(sinceStart * 1.2, 100);
|
|
832
|
+
if (sinceAttempt >= desiredDelay) {
|
|
833
|
+
debug("RETRY", fn.name, args);
|
|
834
|
+
fn.apply(null, args.concat([startTime]));
|
|
835
|
+
} else {
|
|
836
|
+
fs4[gracefulQueue].push(elem);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
if (retryTimer === void 0) {
|
|
840
|
+
retryTimer = setTimeout(retry, 0);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
});
|
|
845
|
+
|
|
846
|
+
// ../../node_modules/fs-extra/lib/fs/index.js
|
|
847
|
+
var require_fs = __commonJS({
|
|
848
|
+
"../../node_modules/fs-extra/lib/fs/index.js"(exports) {
|
|
849
|
+
"use strict";
|
|
850
|
+
var u = require_universalify().fromCallback;
|
|
851
|
+
var fs4 = require_graceful_fs();
|
|
852
|
+
var api = [
|
|
853
|
+
"access",
|
|
854
|
+
"appendFile",
|
|
855
|
+
"chmod",
|
|
856
|
+
"chown",
|
|
857
|
+
"close",
|
|
858
|
+
"copyFile",
|
|
859
|
+
"fchmod",
|
|
860
|
+
"fchown",
|
|
861
|
+
"fdatasync",
|
|
862
|
+
"fstat",
|
|
863
|
+
"fsync",
|
|
864
|
+
"ftruncate",
|
|
865
|
+
"futimes",
|
|
866
|
+
"lchmod",
|
|
867
|
+
"lchown",
|
|
868
|
+
"link",
|
|
869
|
+
"lstat",
|
|
870
|
+
"mkdir",
|
|
871
|
+
"mkdtemp",
|
|
872
|
+
"open",
|
|
873
|
+
"opendir",
|
|
874
|
+
"readdir",
|
|
875
|
+
"readFile",
|
|
876
|
+
"readlink",
|
|
877
|
+
"realpath",
|
|
878
|
+
"rename",
|
|
879
|
+
"rm",
|
|
880
|
+
"rmdir",
|
|
881
|
+
"stat",
|
|
882
|
+
"symlink",
|
|
883
|
+
"truncate",
|
|
884
|
+
"unlink",
|
|
885
|
+
"utimes",
|
|
886
|
+
"writeFile"
|
|
887
|
+
].filter((key) => {
|
|
888
|
+
return typeof fs4[key] === "function";
|
|
889
|
+
});
|
|
890
|
+
Object.assign(exports, fs4);
|
|
891
|
+
api.forEach((method) => {
|
|
892
|
+
exports[method] = u(fs4[method]);
|
|
893
|
+
});
|
|
894
|
+
exports.exists = function(filename, callback) {
|
|
895
|
+
if (typeof callback === "function") {
|
|
896
|
+
return fs4.exists(filename, callback);
|
|
897
|
+
}
|
|
898
|
+
return new Promise((resolve) => {
|
|
899
|
+
return fs4.exists(filename, resolve);
|
|
900
|
+
});
|
|
901
|
+
};
|
|
902
|
+
exports.read = function(fd, buffer, offset, length, position, callback) {
|
|
903
|
+
if (typeof callback === "function") {
|
|
904
|
+
return fs4.read(fd, buffer, offset, length, position, callback);
|
|
905
|
+
}
|
|
906
|
+
return new Promise((resolve, reject) => {
|
|
907
|
+
fs4.read(fd, buffer, offset, length, position, (err, bytesRead, buffer2) => {
|
|
908
|
+
if (err) return reject(err);
|
|
909
|
+
resolve({ bytesRead, buffer: buffer2 });
|
|
910
|
+
});
|
|
911
|
+
});
|
|
912
|
+
};
|
|
913
|
+
exports.write = function(fd, buffer, ...args) {
|
|
914
|
+
if (typeof args[args.length - 1] === "function") {
|
|
915
|
+
return fs4.write(fd, buffer, ...args);
|
|
916
|
+
}
|
|
917
|
+
return new Promise((resolve, reject) => {
|
|
918
|
+
fs4.write(fd, buffer, ...args, (err, bytesWritten, buffer2) => {
|
|
919
|
+
if (err) return reject(err);
|
|
920
|
+
resolve({ bytesWritten, buffer: buffer2 });
|
|
921
|
+
});
|
|
922
|
+
});
|
|
923
|
+
};
|
|
924
|
+
exports.readv = function(fd, buffers, ...args) {
|
|
925
|
+
if (typeof args[args.length - 1] === "function") {
|
|
926
|
+
return fs4.readv(fd, buffers, ...args);
|
|
927
|
+
}
|
|
928
|
+
return new Promise((resolve, reject) => {
|
|
929
|
+
fs4.readv(fd, buffers, ...args, (err, bytesRead, buffers2) => {
|
|
930
|
+
if (err) return reject(err);
|
|
931
|
+
resolve({ bytesRead, buffers: buffers2 });
|
|
932
|
+
});
|
|
933
|
+
});
|
|
934
|
+
};
|
|
935
|
+
exports.writev = function(fd, buffers, ...args) {
|
|
936
|
+
if (typeof args[args.length - 1] === "function") {
|
|
937
|
+
return fs4.writev(fd, buffers, ...args);
|
|
938
|
+
}
|
|
939
|
+
return new Promise((resolve, reject) => {
|
|
940
|
+
fs4.writev(fd, buffers, ...args, (err, bytesWritten, buffers2) => {
|
|
941
|
+
if (err) return reject(err);
|
|
942
|
+
resolve({ bytesWritten, buffers: buffers2 });
|
|
943
|
+
});
|
|
944
|
+
});
|
|
945
|
+
};
|
|
946
|
+
if (typeof fs4.realpath.native === "function") {
|
|
947
|
+
exports.realpath.native = u(fs4.realpath.native);
|
|
948
|
+
} else {
|
|
949
|
+
process.emitWarning(
|
|
950
|
+
"fs.realpath.native is not a function. Is fs being monkey-patched?",
|
|
951
|
+
"Warning",
|
|
952
|
+
"fs-extra-WARN0003"
|
|
953
|
+
);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
});
|
|
957
|
+
|
|
958
|
+
// ../../node_modules/fs-extra/lib/mkdirs/utils.js
|
|
959
|
+
var require_utils = __commonJS({
|
|
960
|
+
"../../node_modules/fs-extra/lib/mkdirs/utils.js"(exports, module) {
|
|
961
|
+
"use strict";
|
|
962
|
+
var path2 = __require("path");
|
|
963
|
+
module.exports.checkPath = function checkPath(pth) {
|
|
964
|
+
if (process.platform === "win32") {
|
|
965
|
+
const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path2.parse(pth).root, ""));
|
|
966
|
+
if (pathHasInvalidWinCharacters) {
|
|
967
|
+
const error = new Error(`Path contains invalid characters: ${pth}`);
|
|
968
|
+
error.code = "EINVAL";
|
|
969
|
+
throw error;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
});
|
|
975
|
+
|
|
976
|
+
// ../../node_modules/fs-extra/lib/mkdirs/make-dir.js
|
|
977
|
+
var require_make_dir = __commonJS({
|
|
978
|
+
"../../node_modules/fs-extra/lib/mkdirs/make-dir.js"(exports, module) {
|
|
979
|
+
"use strict";
|
|
980
|
+
var fs4 = require_fs();
|
|
981
|
+
var { checkPath } = require_utils();
|
|
982
|
+
var getMode = (options) => {
|
|
983
|
+
const defaults = { mode: 511 };
|
|
984
|
+
if (typeof options === "number") return options;
|
|
985
|
+
return { ...defaults, ...options }.mode;
|
|
986
|
+
};
|
|
987
|
+
module.exports.makeDir = async (dir, options) => {
|
|
988
|
+
checkPath(dir);
|
|
989
|
+
return fs4.mkdir(dir, {
|
|
990
|
+
mode: getMode(options),
|
|
991
|
+
recursive: true
|
|
992
|
+
});
|
|
993
|
+
};
|
|
994
|
+
module.exports.makeDirSync = (dir, options) => {
|
|
995
|
+
checkPath(dir);
|
|
996
|
+
return fs4.mkdirSync(dir, {
|
|
997
|
+
mode: getMode(options),
|
|
998
|
+
recursive: true
|
|
999
|
+
});
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
});
|
|
1003
|
+
|
|
1004
|
+
// ../../node_modules/fs-extra/lib/mkdirs/index.js
|
|
1005
|
+
var require_mkdirs = __commonJS({
|
|
1006
|
+
"../../node_modules/fs-extra/lib/mkdirs/index.js"(exports, module) {
|
|
1007
|
+
"use strict";
|
|
1008
|
+
var u = require_universalify().fromPromise;
|
|
1009
|
+
var { makeDir: _makeDir, makeDirSync } = require_make_dir();
|
|
1010
|
+
var makeDir = u(_makeDir);
|
|
1011
|
+
module.exports = {
|
|
1012
|
+
mkdirs: makeDir,
|
|
1013
|
+
mkdirsSync: makeDirSync,
|
|
1014
|
+
// alias
|
|
1015
|
+
mkdirp: makeDir,
|
|
1016
|
+
mkdirpSync: makeDirSync,
|
|
1017
|
+
ensureDir: makeDir,
|
|
1018
|
+
ensureDirSync: makeDirSync
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
});
|
|
1022
|
+
|
|
1023
|
+
// ../../node_modules/fs-extra/lib/path-exists/index.js
|
|
1024
|
+
var require_path_exists = __commonJS({
|
|
1025
|
+
"../../node_modules/fs-extra/lib/path-exists/index.js"(exports, module) {
|
|
1026
|
+
"use strict";
|
|
1027
|
+
var u = require_universalify().fromPromise;
|
|
1028
|
+
var fs4 = require_fs();
|
|
1029
|
+
function pathExists(path2) {
|
|
1030
|
+
return fs4.access(path2).then(() => true).catch(() => false);
|
|
1031
|
+
}
|
|
1032
|
+
module.exports = {
|
|
1033
|
+
pathExists: u(pathExists),
|
|
1034
|
+
pathExistsSync: fs4.existsSync
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
1037
|
+
});
|
|
1038
|
+
|
|
1039
|
+
// ../../node_modules/fs-extra/lib/util/utimes.js
|
|
1040
|
+
var require_utimes = __commonJS({
|
|
1041
|
+
"../../node_modules/fs-extra/lib/util/utimes.js"(exports, module) {
|
|
1042
|
+
"use strict";
|
|
1043
|
+
var fs4 = require_fs();
|
|
1044
|
+
var u = require_universalify().fromPromise;
|
|
1045
|
+
async function utimesMillis(path2, atime, mtime) {
|
|
1046
|
+
const fd = await fs4.open(path2, "r+");
|
|
1047
|
+
let closeErr = null;
|
|
1048
|
+
try {
|
|
1049
|
+
await fs4.futimes(fd, atime, mtime);
|
|
1050
|
+
} finally {
|
|
1051
|
+
try {
|
|
1052
|
+
await fs4.close(fd);
|
|
1053
|
+
} catch (e) {
|
|
1054
|
+
closeErr = e;
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
if (closeErr) {
|
|
1058
|
+
throw closeErr;
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
function utimesMillisSync(path2, atime, mtime) {
|
|
1062
|
+
const fd = fs4.openSync(path2, "r+");
|
|
1063
|
+
fs4.futimesSync(fd, atime, mtime);
|
|
1064
|
+
return fs4.closeSync(fd);
|
|
1065
|
+
}
|
|
1066
|
+
module.exports = {
|
|
1067
|
+
utimesMillis: u(utimesMillis),
|
|
1068
|
+
utimesMillisSync
|
|
1069
|
+
};
|
|
1070
|
+
}
|
|
1071
|
+
});
|
|
1072
|
+
|
|
1073
|
+
// ../../node_modules/fs-extra/lib/util/stat.js
|
|
1074
|
+
var require_stat = __commonJS({
|
|
1075
|
+
"../../node_modules/fs-extra/lib/util/stat.js"(exports, module) {
|
|
1076
|
+
"use strict";
|
|
1077
|
+
var fs4 = require_fs();
|
|
1078
|
+
var path2 = __require("path");
|
|
1079
|
+
var u = require_universalify().fromPromise;
|
|
1080
|
+
function getStats(src, dest, opts) {
|
|
1081
|
+
const statFunc = opts.dereference ? (file) => fs4.stat(file, { bigint: true }) : (file) => fs4.lstat(file, { bigint: true });
|
|
1082
|
+
return Promise.all([
|
|
1083
|
+
statFunc(src),
|
|
1084
|
+
statFunc(dest).catch((err) => {
|
|
1085
|
+
if (err.code === "ENOENT") return null;
|
|
1086
|
+
throw err;
|
|
1087
|
+
})
|
|
1088
|
+
]).then(([srcStat, destStat]) => ({ srcStat, destStat }));
|
|
1089
|
+
}
|
|
1090
|
+
function getStatsSync(src, dest, opts) {
|
|
1091
|
+
let destStat;
|
|
1092
|
+
const statFunc = opts.dereference ? (file) => fs4.statSync(file, { bigint: true }) : (file) => fs4.lstatSync(file, { bigint: true });
|
|
1093
|
+
const srcStat = statFunc(src);
|
|
1094
|
+
try {
|
|
1095
|
+
destStat = statFunc(dest);
|
|
1096
|
+
} catch (err) {
|
|
1097
|
+
if (err.code === "ENOENT") return { srcStat, destStat: null };
|
|
1098
|
+
throw err;
|
|
1099
|
+
}
|
|
1100
|
+
return { srcStat, destStat };
|
|
1101
|
+
}
|
|
1102
|
+
async function checkPaths(src, dest, funcName, opts) {
|
|
1103
|
+
const { srcStat, destStat } = await getStats(src, dest, opts);
|
|
1104
|
+
if (destStat) {
|
|
1105
|
+
if (areIdentical(srcStat, destStat)) {
|
|
1106
|
+
const srcBaseName = path2.basename(src);
|
|
1107
|
+
const destBaseName = path2.basename(dest);
|
|
1108
|
+
if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
|
|
1109
|
+
return { srcStat, destStat, isChangingCase: true };
|
|
1110
|
+
}
|
|
1111
|
+
throw new Error("Source and destination must not be the same.");
|
|
1112
|
+
}
|
|
1113
|
+
if (srcStat.isDirectory() && !destStat.isDirectory()) {
|
|
1114
|
+
throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`);
|
|
1115
|
+
}
|
|
1116
|
+
if (!srcStat.isDirectory() && destStat.isDirectory()) {
|
|
1117
|
+
throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`);
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
|
1121
|
+
throw new Error(errMsg(src, dest, funcName));
|
|
1122
|
+
}
|
|
1123
|
+
return { srcStat, destStat };
|
|
1124
|
+
}
|
|
1125
|
+
function checkPathsSync(src, dest, funcName, opts) {
|
|
1126
|
+
const { srcStat, destStat } = getStatsSync(src, dest, opts);
|
|
1127
|
+
if (destStat) {
|
|
1128
|
+
if (areIdentical(srcStat, destStat)) {
|
|
1129
|
+
const srcBaseName = path2.basename(src);
|
|
1130
|
+
const destBaseName = path2.basename(dest);
|
|
1131
|
+
if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
|
|
1132
|
+
return { srcStat, destStat, isChangingCase: true };
|
|
1133
|
+
}
|
|
1134
|
+
throw new Error("Source and destination must not be the same.");
|
|
1135
|
+
}
|
|
1136
|
+
if (srcStat.isDirectory() && !destStat.isDirectory()) {
|
|
1137
|
+
throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`);
|
|
1138
|
+
}
|
|
1139
|
+
if (!srcStat.isDirectory() && destStat.isDirectory()) {
|
|
1140
|
+
throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`);
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
|
1144
|
+
throw new Error(errMsg(src, dest, funcName));
|
|
1145
|
+
}
|
|
1146
|
+
return { srcStat, destStat };
|
|
1147
|
+
}
|
|
1148
|
+
async function checkParentPaths(src, srcStat, dest, funcName) {
|
|
1149
|
+
const srcParent = path2.resolve(path2.dirname(src));
|
|
1150
|
+
const destParent = path2.resolve(path2.dirname(dest));
|
|
1151
|
+
if (destParent === srcParent || destParent === path2.parse(destParent).root) return;
|
|
1152
|
+
let destStat;
|
|
1153
|
+
try {
|
|
1154
|
+
destStat = await fs4.stat(destParent, { bigint: true });
|
|
1155
|
+
} catch (err) {
|
|
1156
|
+
if (err.code === "ENOENT") return;
|
|
1157
|
+
throw err;
|
|
1158
|
+
}
|
|
1159
|
+
if (areIdentical(srcStat, destStat)) {
|
|
1160
|
+
throw new Error(errMsg(src, dest, funcName));
|
|
1161
|
+
}
|
|
1162
|
+
return checkParentPaths(src, srcStat, destParent, funcName);
|
|
1163
|
+
}
|
|
1164
|
+
function checkParentPathsSync(src, srcStat, dest, funcName) {
|
|
1165
|
+
const srcParent = path2.resolve(path2.dirname(src));
|
|
1166
|
+
const destParent = path2.resolve(path2.dirname(dest));
|
|
1167
|
+
if (destParent === srcParent || destParent === path2.parse(destParent).root) return;
|
|
1168
|
+
let destStat;
|
|
1169
|
+
try {
|
|
1170
|
+
destStat = fs4.statSync(destParent, { bigint: true });
|
|
1171
|
+
} catch (err) {
|
|
1172
|
+
if (err.code === "ENOENT") return;
|
|
1173
|
+
throw err;
|
|
1174
|
+
}
|
|
1175
|
+
if (areIdentical(srcStat, destStat)) {
|
|
1176
|
+
throw new Error(errMsg(src, dest, funcName));
|
|
1177
|
+
}
|
|
1178
|
+
return checkParentPathsSync(src, srcStat, destParent, funcName);
|
|
1179
|
+
}
|
|
1180
|
+
function areIdentical(srcStat, destStat) {
|
|
1181
|
+
return destStat.ino && destStat.dev && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev;
|
|
1182
|
+
}
|
|
1183
|
+
function isSrcSubdir(src, dest) {
|
|
1184
|
+
const srcArr = path2.resolve(src).split(path2.sep).filter((i) => i);
|
|
1185
|
+
const destArr = path2.resolve(dest).split(path2.sep).filter((i) => i);
|
|
1186
|
+
return srcArr.every((cur, i) => destArr[i] === cur);
|
|
1187
|
+
}
|
|
1188
|
+
function errMsg(src, dest, funcName) {
|
|
1189
|
+
return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`;
|
|
1190
|
+
}
|
|
1191
|
+
module.exports = {
|
|
1192
|
+
// checkPaths
|
|
1193
|
+
checkPaths: u(checkPaths),
|
|
1194
|
+
checkPathsSync,
|
|
1195
|
+
// checkParent
|
|
1196
|
+
checkParentPaths: u(checkParentPaths),
|
|
1197
|
+
checkParentPathsSync,
|
|
1198
|
+
// Misc
|
|
1199
|
+
isSrcSubdir,
|
|
1200
|
+
areIdentical
|
|
1201
|
+
};
|
|
1202
|
+
}
|
|
1203
|
+
});
|
|
1204
|
+
|
|
1205
|
+
// ../../node_modules/fs-extra/lib/copy/copy.js
|
|
1206
|
+
var require_copy = __commonJS({
|
|
1207
|
+
"../../node_modules/fs-extra/lib/copy/copy.js"(exports, module) {
|
|
1208
|
+
"use strict";
|
|
1209
|
+
var fs4 = require_fs();
|
|
1210
|
+
var path2 = __require("path");
|
|
1211
|
+
var { mkdirs } = require_mkdirs();
|
|
1212
|
+
var { pathExists } = require_path_exists();
|
|
1213
|
+
var { utimesMillis } = require_utimes();
|
|
1214
|
+
var stat = require_stat();
|
|
1215
|
+
async function copy(src, dest, opts = {}) {
|
|
1216
|
+
if (typeof opts === "function") {
|
|
1217
|
+
opts = { filter: opts };
|
|
1218
|
+
}
|
|
1219
|
+
opts.clobber = "clobber" in opts ? !!opts.clobber : true;
|
|
1220
|
+
opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
|
|
1221
|
+
if (opts.preserveTimestamps && process.arch === "ia32") {
|
|
1222
|
+
process.emitWarning(
|
|
1223
|
+
"Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269",
|
|
1224
|
+
"Warning",
|
|
1225
|
+
"fs-extra-WARN0001"
|
|
1226
|
+
);
|
|
1227
|
+
}
|
|
1228
|
+
const { srcStat, destStat } = await stat.checkPaths(src, dest, "copy", opts);
|
|
1229
|
+
await stat.checkParentPaths(src, srcStat, dest, "copy");
|
|
1230
|
+
const include = await runFilter(src, dest, opts);
|
|
1231
|
+
if (!include) return;
|
|
1232
|
+
const destParent = path2.dirname(dest);
|
|
1233
|
+
const dirExists = await pathExists(destParent);
|
|
1234
|
+
if (!dirExists) {
|
|
1235
|
+
await mkdirs(destParent);
|
|
1236
|
+
}
|
|
1237
|
+
await getStatsAndPerformCopy(destStat, src, dest, opts);
|
|
1238
|
+
}
|
|
1239
|
+
async function runFilter(src, dest, opts) {
|
|
1240
|
+
if (!opts.filter) return true;
|
|
1241
|
+
return opts.filter(src, dest);
|
|
1242
|
+
}
|
|
1243
|
+
async function getStatsAndPerformCopy(destStat, src, dest, opts) {
|
|
1244
|
+
const statFn = opts.dereference ? fs4.stat : fs4.lstat;
|
|
1245
|
+
const srcStat = await statFn(src);
|
|
1246
|
+
if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts);
|
|
1247
|
+
if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts);
|
|
1248
|
+
if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts);
|
|
1249
|
+
if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`);
|
|
1250
|
+
if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`);
|
|
1251
|
+
throw new Error(`Unknown file: ${src}`);
|
|
1252
|
+
}
|
|
1253
|
+
async function onFile(srcStat, destStat, src, dest, opts) {
|
|
1254
|
+
if (!destStat) return copyFile(srcStat, src, dest, opts);
|
|
1255
|
+
if (opts.overwrite) {
|
|
1256
|
+
await fs4.unlink(dest);
|
|
1257
|
+
return copyFile(srcStat, src, dest, opts);
|
|
1258
|
+
}
|
|
1259
|
+
if (opts.errorOnExist) {
|
|
1260
|
+
throw new Error(`'${dest}' already exists`);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
async function copyFile(srcStat, src, dest, opts) {
|
|
1264
|
+
await fs4.copyFile(src, dest);
|
|
1265
|
+
if (opts.preserveTimestamps) {
|
|
1266
|
+
if (fileIsNotWritable(srcStat.mode)) {
|
|
1267
|
+
await makeFileWritable(dest, srcStat.mode);
|
|
1268
|
+
}
|
|
1269
|
+
const updatedSrcStat = await fs4.stat(src);
|
|
1270
|
+
await utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
|
|
1271
|
+
}
|
|
1272
|
+
return fs4.chmod(dest, srcStat.mode);
|
|
1273
|
+
}
|
|
1274
|
+
function fileIsNotWritable(srcMode) {
|
|
1275
|
+
return (srcMode & 128) === 0;
|
|
1276
|
+
}
|
|
1277
|
+
function makeFileWritable(dest, srcMode) {
|
|
1278
|
+
return fs4.chmod(dest, srcMode | 128);
|
|
1279
|
+
}
|
|
1280
|
+
async function onDir(srcStat, destStat, src, dest, opts) {
|
|
1281
|
+
if (!destStat) {
|
|
1282
|
+
await fs4.mkdir(dest);
|
|
1283
|
+
}
|
|
1284
|
+
const items = await fs4.readdir(src);
|
|
1285
|
+
await Promise.all(items.map(async (item) => {
|
|
1286
|
+
const srcItem = path2.join(src, item);
|
|
1287
|
+
const destItem = path2.join(dest, item);
|
|
1288
|
+
const include = await runFilter(srcItem, destItem, opts);
|
|
1289
|
+
if (!include) return;
|
|
1290
|
+
const { destStat: destStat2 } = await stat.checkPaths(srcItem, destItem, "copy", opts);
|
|
1291
|
+
return getStatsAndPerformCopy(destStat2, srcItem, destItem, opts);
|
|
1292
|
+
}));
|
|
1293
|
+
if (!destStat) {
|
|
1294
|
+
await fs4.chmod(dest, srcStat.mode);
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
async function onLink(destStat, src, dest, opts) {
|
|
1298
|
+
let resolvedSrc = await fs4.readlink(src);
|
|
1299
|
+
if (opts.dereference) {
|
|
1300
|
+
resolvedSrc = path2.resolve(process.cwd(), resolvedSrc);
|
|
1301
|
+
}
|
|
1302
|
+
if (!destStat) {
|
|
1303
|
+
return fs4.symlink(resolvedSrc, dest);
|
|
1304
|
+
}
|
|
1305
|
+
let resolvedDest = null;
|
|
1306
|
+
try {
|
|
1307
|
+
resolvedDest = await fs4.readlink(dest);
|
|
1308
|
+
} catch (e) {
|
|
1309
|
+
if (e.code === "EINVAL" || e.code === "UNKNOWN") return fs4.symlink(resolvedSrc, dest);
|
|
1310
|
+
throw e;
|
|
1311
|
+
}
|
|
1312
|
+
if (opts.dereference) {
|
|
1313
|
+
resolvedDest = path2.resolve(process.cwd(), resolvedDest);
|
|
1314
|
+
}
|
|
1315
|
+
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
1316
|
+
throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
|
|
1317
|
+
}
|
|
1318
|
+
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
|
|
1319
|
+
throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
|
|
1320
|
+
}
|
|
1321
|
+
await fs4.unlink(dest);
|
|
1322
|
+
return fs4.symlink(resolvedSrc, dest);
|
|
1323
|
+
}
|
|
1324
|
+
module.exports = copy;
|
|
1325
|
+
}
|
|
1326
|
+
});
|
|
1327
|
+
|
|
1328
|
+
// ../../node_modules/fs-extra/lib/copy/copy-sync.js
|
|
1329
|
+
var require_copy_sync = __commonJS({
|
|
1330
|
+
"../../node_modules/fs-extra/lib/copy/copy-sync.js"(exports, module) {
|
|
1331
|
+
"use strict";
|
|
1332
|
+
var fs4 = require_graceful_fs();
|
|
1333
|
+
var path2 = __require("path");
|
|
1334
|
+
var mkdirsSync = require_mkdirs().mkdirsSync;
|
|
1335
|
+
var utimesMillisSync = require_utimes().utimesMillisSync;
|
|
1336
|
+
var stat = require_stat();
|
|
1337
|
+
function copySync(src, dest, opts) {
|
|
1338
|
+
if (typeof opts === "function") {
|
|
1339
|
+
opts = { filter: opts };
|
|
1340
|
+
}
|
|
1341
|
+
opts = opts || {};
|
|
1342
|
+
opts.clobber = "clobber" in opts ? !!opts.clobber : true;
|
|
1343
|
+
opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
|
|
1344
|
+
if (opts.preserveTimestamps && process.arch === "ia32") {
|
|
1345
|
+
process.emitWarning(
|
|
1346
|
+
"Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269",
|
|
1347
|
+
"Warning",
|
|
1348
|
+
"fs-extra-WARN0002"
|
|
1349
|
+
);
|
|
1350
|
+
}
|
|
1351
|
+
const { srcStat, destStat } = stat.checkPathsSync(src, dest, "copy", opts);
|
|
1352
|
+
stat.checkParentPathsSync(src, srcStat, dest, "copy");
|
|
1353
|
+
if (opts.filter && !opts.filter(src, dest)) return;
|
|
1354
|
+
const destParent = path2.dirname(dest);
|
|
1355
|
+
if (!fs4.existsSync(destParent)) mkdirsSync(destParent);
|
|
1356
|
+
return getStats(destStat, src, dest, opts);
|
|
1357
|
+
}
|
|
1358
|
+
function getStats(destStat, src, dest, opts) {
|
|
1359
|
+
const statSync = opts.dereference ? fs4.statSync : fs4.lstatSync;
|
|
1360
|
+
const srcStat = statSync(src);
|
|
1361
|
+
if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts);
|
|
1362
|
+
else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts);
|
|
1363
|
+
else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts);
|
|
1364
|
+
else if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`);
|
|
1365
|
+
else if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`);
|
|
1366
|
+
throw new Error(`Unknown file: ${src}`);
|
|
1367
|
+
}
|
|
1368
|
+
function onFile(srcStat, destStat, src, dest, opts) {
|
|
1369
|
+
if (!destStat) return copyFile(srcStat, src, dest, opts);
|
|
1370
|
+
return mayCopyFile(srcStat, src, dest, opts);
|
|
1371
|
+
}
|
|
1372
|
+
function mayCopyFile(srcStat, src, dest, opts) {
|
|
1373
|
+
if (opts.overwrite) {
|
|
1374
|
+
fs4.unlinkSync(dest);
|
|
1375
|
+
return copyFile(srcStat, src, dest, opts);
|
|
1376
|
+
} else if (opts.errorOnExist) {
|
|
1377
|
+
throw new Error(`'${dest}' already exists`);
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
function copyFile(srcStat, src, dest, opts) {
|
|
1381
|
+
fs4.copyFileSync(src, dest);
|
|
1382
|
+
if (opts.preserveTimestamps) handleTimestamps(srcStat.mode, src, dest);
|
|
1383
|
+
return setDestMode(dest, srcStat.mode);
|
|
1384
|
+
}
|
|
1385
|
+
function handleTimestamps(srcMode, src, dest) {
|
|
1386
|
+
if (fileIsNotWritable(srcMode)) makeFileWritable(dest, srcMode);
|
|
1387
|
+
return setDestTimestamps(src, dest);
|
|
1388
|
+
}
|
|
1389
|
+
function fileIsNotWritable(srcMode) {
|
|
1390
|
+
return (srcMode & 128) === 0;
|
|
1391
|
+
}
|
|
1392
|
+
function makeFileWritable(dest, srcMode) {
|
|
1393
|
+
return setDestMode(dest, srcMode | 128);
|
|
1394
|
+
}
|
|
1395
|
+
function setDestMode(dest, srcMode) {
|
|
1396
|
+
return fs4.chmodSync(dest, srcMode);
|
|
1397
|
+
}
|
|
1398
|
+
function setDestTimestamps(src, dest) {
|
|
1399
|
+
const updatedSrcStat = fs4.statSync(src);
|
|
1400
|
+
return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
|
|
1401
|
+
}
|
|
1402
|
+
function onDir(srcStat, destStat, src, dest, opts) {
|
|
1403
|
+
if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts);
|
|
1404
|
+
return copyDir(src, dest, opts);
|
|
1405
|
+
}
|
|
1406
|
+
function mkDirAndCopy(srcMode, src, dest, opts) {
|
|
1407
|
+
fs4.mkdirSync(dest);
|
|
1408
|
+
copyDir(src, dest, opts);
|
|
1409
|
+
return setDestMode(dest, srcMode);
|
|
1410
|
+
}
|
|
1411
|
+
function copyDir(src, dest, opts) {
|
|
1412
|
+
fs4.readdirSync(src).forEach((item) => copyDirItem(item, src, dest, opts));
|
|
1413
|
+
}
|
|
1414
|
+
function copyDirItem(item, src, dest, opts) {
|
|
1415
|
+
const srcItem = path2.join(src, item);
|
|
1416
|
+
const destItem = path2.join(dest, item);
|
|
1417
|
+
if (opts.filter && !opts.filter(srcItem, destItem)) return;
|
|
1418
|
+
const { destStat } = stat.checkPathsSync(srcItem, destItem, "copy", opts);
|
|
1419
|
+
return getStats(destStat, srcItem, destItem, opts);
|
|
1420
|
+
}
|
|
1421
|
+
function onLink(destStat, src, dest, opts) {
|
|
1422
|
+
let resolvedSrc = fs4.readlinkSync(src);
|
|
1423
|
+
if (opts.dereference) {
|
|
1424
|
+
resolvedSrc = path2.resolve(process.cwd(), resolvedSrc);
|
|
1425
|
+
}
|
|
1426
|
+
if (!destStat) {
|
|
1427
|
+
return fs4.symlinkSync(resolvedSrc, dest);
|
|
1428
|
+
} else {
|
|
1429
|
+
let resolvedDest;
|
|
1430
|
+
try {
|
|
1431
|
+
resolvedDest = fs4.readlinkSync(dest);
|
|
1432
|
+
} catch (err) {
|
|
1433
|
+
if (err.code === "EINVAL" || err.code === "UNKNOWN") return fs4.symlinkSync(resolvedSrc, dest);
|
|
1434
|
+
throw err;
|
|
1435
|
+
}
|
|
1436
|
+
if (opts.dereference) {
|
|
1437
|
+
resolvedDest = path2.resolve(process.cwd(), resolvedDest);
|
|
1438
|
+
}
|
|
1439
|
+
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
1440
|
+
throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
|
|
1441
|
+
}
|
|
1442
|
+
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
|
|
1443
|
+
throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
|
|
1444
|
+
}
|
|
1445
|
+
return copyLink(resolvedSrc, dest);
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
function copyLink(resolvedSrc, dest) {
|
|
1449
|
+
fs4.unlinkSync(dest);
|
|
1450
|
+
return fs4.symlinkSync(resolvedSrc, dest);
|
|
1451
|
+
}
|
|
1452
|
+
module.exports = copySync;
|
|
1453
|
+
}
|
|
1454
|
+
});
|
|
1455
|
+
|
|
1456
|
+
// ../../node_modules/fs-extra/lib/copy/index.js
|
|
1457
|
+
var require_copy2 = __commonJS({
|
|
1458
|
+
"../../node_modules/fs-extra/lib/copy/index.js"(exports, module) {
|
|
1459
|
+
"use strict";
|
|
1460
|
+
var u = require_universalify().fromPromise;
|
|
1461
|
+
module.exports = {
|
|
1462
|
+
copy: u(require_copy()),
|
|
1463
|
+
copySync: require_copy_sync()
|
|
1464
|
+
};
|
|
1465
|
+
}
|
|
1466
|
+
});
|
|
1467
|
+
|
|
1468
|
+
// ../../node_modules/fs-extra/lib/remove/index.js
|
|
1469
|
+
var require_remove = __commonJS({
|
|
1470
|
+
"../../node_modules/fs-extra/lib/remove/index.js"(exports, module) {
|
|
1471
|
+
"use strict";
|
|
1472
|
+
var fs4 = require_graceful_fs();
|
|
1473
|
+
var u = require_universalify().fromCallback;
|
|
1474
|
+
function remove2(path2, callback) {
|
|
1475
|
+
fs4.rm(path2, { recursive: true, force: true }, callback);
|
|
1476
|
+
}
|
|
1477
|
+
function removeSync(path2) {
|
|
1478
|
+
fs4.rmSync(path2, { recursive: true, force: true });
|
|
1479
|
+
}
|
|
1480
|
+
module.exports = {
|
|
1481
|
+
remove: u(remove2),
|
|
1482
|
+
removeSync
|
|
1483
|
+
};
|
|
1484
|
+
}
|
|
1485
|
+
});
|
|
1486
|
+
|
|
1487
|
+
// ../../node_modules/fs-extra/lib/empty/index.js
|
|
1488
|
+
var require_empty = __commonJS({
|
|
1489
|
+
"../../node_modules/fs-extra/lib/empty/index.js"(exports, module) {
|
|
1490
|
+
"use strict";
|
|
1491
|
+
var u = require_universalify().fromPromise;
|
|
1492
|
+
var fs4 = require_fs();
|
|
1493
|
+
var path2 = __require("path");
|
|
1494
|
+
var mkdir = require_mkdirs();
|
|
1495
|
+
var remove2 = require_remove();
|
|
1496
|
+
var emptyDir = u(async function emptyDir2(dir) {
|
|
1497
|
+
let items;
|
|
1498
|
+
try {
|
|
1499
|
+
items = await fs4.readdir(dir);
|
|
1500
|
+
} catch {
|
|
1501
|
+
return mkdir.mkdirs(dir);
|
|
1502
|
+
}
|
|
1503
|
+
return Promise.all(items.map((item) => remove2.remove(path2.join(dir, item))));
|
|
1504
|
+
});
|
|
1505
|
+
function emptyDirSync(dir) {
|
|
1506
|
+
let items;
|
|
1507
|
+
try {
|
|
1508
|
+
items = fs4.readdirSync(dir);
|
|
1509
|
+
} catch {
|
|
1510
|
+
return mkdir.mkdirsSync(dir);
|
|
1511
|
+
}
|
|
1512
|
+
items.forEach((item) => {
|
|
1513
|
+
item = path2.join(dir, item);
|
|
1514
|
+
remove2.removeSync(item);
|
|
1515
|
+
});
|
|
1516
|
+
}
|
|
1517
|
+
module.exports = {
|
|
1518
|
+
emptyDirSync,
|
|
1519
|
+
emptydirSync: emptyDirSync,
|
|
1520
|
+
emptyDir,
|
|
1521
|
+
emptydir: emptyDir
|
|
1522
|
+
};
|
|
1523
|
+
}
|
|
1524
|
+
});
|
|
1525
|
+
|
|
1526
|
+
// ../../node_modules/fs-extra/lib/ensure/file.js
|
|
1527
|
+
var require_file = __commonJS({
|
|
1528
|
+
"../../node_modules/fs-extra/lib/ensure/file.js"(exports, module) {
|
|
1529
|
+
"use strict";
|
|
1530
|
+
var u = require_universalify().fromPromise;
|
|
1531
|
+
var path2 = __require("path");
|
|
1532
|
+
var fs4 = require_fs();
|
|
1533
|
+
var mkdir = require_mkdirs();
|
|
1534
|
+
async function createFile(file) {
|
|
1535
|
+
let stats;
|
|
1536
|
+
try {
|
|
1537
|
+
stats = await fs4.stat(file);
|
|
1538
|
+
} catch {
|
|
1539
|
+
}
|
|
1540
|
+
if (stats && stats.isFile()) return;
|
|
1541
|
+
const dir = path2.dirname(file);
|
|
1542
|
+
let dirStats = null;
|
|
1543
|
+
try {
|
|
1544
|
+
dirStats = await fs4.stat(dir);
|
|
1545
|
+
} catch (err) {
|
|
1546
|
+
if (err.code === "ENOENT") {
|
|
1547
|
+
await mkdir.mkdirs(dir);
|
|
1548
|
+
await fs4.writeFile(file, "");
|
|
1549
|
+
return;
|
|
1550
|
+
} else {
|
|
1551
|
+
throw err;
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
if (dirStats.isDirectory()) {
|
|
1555
|
+
await fs4.writeFile(file, "");
|
|
1556
|
+
} else {
|
|
1557
|
+
await fs4.readdir(dir);
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
function createFileSync(file) {
|
|
1561
|
+
let stats;
|
|
1562
|
+
try {
|
|
1563
|
+
stats = fs4.statSync(file);
|
|
1564
|
+
} catch {
|
|
1565
|
+
}
|
|
1566
|
+
if (stats && stats.isFile()) return;
|
|
1567
|
+
const dir = path2.dirname(file);
|
|
1568
|
+
try {
|
|
1569
|
+
if (!fs4.statSync(dir).isDirectory()) {
|
|
1570
|
+
fs4.readdirSync(dir);
|
|
1571
|
+
}
|
|
1572
|
+
} catch (err) {
|
|
1573
|
+
if (err && err.code === "ENOENT") mkdir.mkdirsSync(dir);
|
|
1574
|
+
else throw err;
|
|
1575
|
+
}
|
|
1576
|
+
fs4.writeFileSync(file, "");
|
|
1577
|
+
}
|
|
1578
|
+
module.exports = {
|
|
1579
|
+
createFile: u(createFile),
|
|
1580
|
+
createFileSync
|
|
1581
|
+
};
|
|
1582
|
+
}
|
|
1583
|
+
});
|
|
1584
|
+
|
|
1585
|
+
// ../../node_modules/fs-extra/lib/ensure/link.js
|
|
1586
|
+
var require_link = __commonJS({
|
|
1587
|
+
"../../node_modules/fs-extra/lib/ensure/link.js"(exports, module) {
|
|
1588
|
+
"use strict";
|
|
1589
|
+
var u = require_universalify().fromPromise;
|
|
1590
|
+
var path2 = __require("path");
|
|
1591
|
+
var fs4 = require_fs();
|
|
1592
|
+
var mkdir = require_mkdirs();
|
|
1593
|
+
var { pathExists } = require_path_exists();
|
|
1594
|
+
var { areIdentical } = require_stat();
|
|
1595
|
+
async function createLink(srcpath, dstpath) {
|
|
1596
|
+
let dstStat;
|
|
1597
|
+
try {
|
|
1598
|
+
dstStat = await fs4.lstat(dstpath);
|
|
1599
|
+
} catch {
|
|
1600
|
+
}
|
|
1601
|
+
let srcStat;
|
|
1602
|
+
try {
|
|
1603
|
+
srcStat = await fs4.lstat(srcpath);
|
|
1604
|
+
} catch (err) {
|
|
1605
|
+
err.message = err.message.replace("lstat", "ensureLink");
|
|
1606
|
+
throw err;
|
|
1607
|
+
}
|
|
1608
|
+
if (dstStat && areIdentical(srcStat, dstStat)) return;
|
|
1609
|
+
const dir = path2.dirname(dstpath);
|
|
1610
|
+
const dirExists = await pathExists(dir);
|
|
1611
|
+
if (!dirExists) {
|
|
1612
|
+
await mkdir.mkdirs(dir);
|
|
1613
|
+
}
|
|
1614
|
+
await fs4.link(srcpath, dstpath);
|
|
1615
|
+
}
|
|
1616
|
+
function createLinkSync(srcpath, dstpath) {
|
|
1617
|
+
let dstStat;
|
|
1618
|
+
try {
|
|
1619
|
+
dstStat = fs4.lstatSync(dstpath);
|
|
1620
|
+
} catch {
|
|
1621
|
+
}
|
|
1622
|
+
try {
|
|
1623
|
+
const srcStat = fs4.lstatSync(srcpath);
|
|
1624
|
+
if (dstStat && areIdentical(srcStat, dstStat)) return;
|
|
1625
|
+
} catch (err) {
|
|
1626
|
+
err.message = err.message.replace("lstat", "ensureLink");
|
|
1627
|
+
throw err;
|
|
1628
|
+
}
|
|
1629
|
+
const dir = path2.dirname(dstpath);
|
|
1630
|
+
const dirExists = fs4.existsSync(dir);
|
|
1631
|
+
if (dirExists) return fs4.linkSync(srcpath, dstpath);
|
|
1632
|
+
mkdir.mkdirsSync(dir);
|
|
1633
|
+
return fs4.linkSync(srcpath, dstpath);
|
|
1634
|
+
}
|
|
1635
|
+
module.exports = {
|
|
1636
|
+
createLink: u(createLink),
|
|
1637
|
+
createLinkSync
|
|
1638
|
+
};
|
|
1639
|
+
}
|
|
1640
|
+
});
|
|
1641
|
+
|
|
1642
|
+
// ../../node_modules/fs-extra/lib/ensure/symlink-paths.js
|
|
1643
|
+
var require_symlink_paths = __commonJS({
|
|
1644
|
+
"../../node_modules/fs-extra/lib/ensure/symlink-paths.js"(exports, module) {
|
|
1645
|
+
"use strict";
|
|
1646
|
+
var path2 = __require("path");
|
|
1647
|
+
var fs4 = require_fs();
|
|
1648
|
+
var { pathExists } = require_path_exists();
|
|
1649
|
+
var u = require_universalify().fromPromise;
|
|
1650
|
+
async function symlinkPaths(srcpath, dstpath) {
|
|
1651
|
+
if (path2.isAbsolute(srcpath)) {
|
|
1652
|
+
try {
|
|
1653
|
+
await fs4.lstat(srcpath);
|
|
1654
|
+
} catch (err) {
|
|
1655
|
+
err.message = err.message.replace("lstat", "ensureSymlink");
|
|
1656
|
+
throw err;
|
|
1657
|
+
}
|
|
1658
|
+
return {
|
|
1659
|
+
toCwd: srcpath,
|
|
1660
|
+
toDst: srcpath
|
|
1661
|
+
};
|
|
1662
|
+
}
|
|
1663
|
+
const dstdir = path2.dirname(dstpath);
|
|
1664
|
+
const relativeToDst = path2.join(dstdir, srcpath);
|
|
1665
|
+
const exists = await pathExists(relativeToDst);
|
|
1666
|
+
if (exists) {
|
|
1667
|
+
return {
|
|
1668
|
+
toCwd: relativeToDst,
|
|
1669
|
+
toDst: srcpath
|
|
1670
|
+
};
|
|
1671
|
+
}
|
|
1672
|
+
try {
|
|
1673
|
+
await fs4.lstat(srcpath);
|
|
1674
|
+
} catch (err) {
|
|
1675
|
+
err.message = err.message.replace("lstat", "ensureSymlink");
|
|
1676
|
+
throw err;
|
|
1677
|
+
}
|
|
1678
|
+
return {
|
|
1679
|
+
toCwd: srcpath,
|
|
1680
|
+
toDst: path2.relative(dstdir, srcpath)
|
|
1681
|
+
};
|
|
1682
|
+
}
|
|
1683
|
+
function symlinkPathsSync(srcpath, dstpath) {
|
|
1684
|
+
if (path2.isAbsolute(srcpath)) {
|
|
1685
|
+
const exists2 = fs4.existsSync(srcpath);
|
|
1686
|
+
if (!exists2) throw new Error("absolute srcpath does not exist");
|
|
1687
|
+
return {
|
|
1688
|
+
toCwd: srcpath,
|
|
1689
|
+
toDst: srcpath
|
|
1690
|
+
};
|
|
1691
|
+
}
|
|
1692
|
+
const dstdir = path2.dirname(dstpath);
|
|
1693
|
+
const relativeToDst = path2.join(dstdir, srcpath);
|
|
1694
|
+
const exists = fs4.existsSync(relativeToDst);
|
|
1695
|
+
if (exists) {
|
|
1696
|
+
return {
|
|
1697
|
+
toCwd: relativeToDst,
|
|
1698
|
+
toDst: srcpath
|
|
1699
|
+
};
|
|
1700
|
+
}
|
|
1701
|
+
const srcExists = fs4.existsSync(srcpath);
|
|
1702
|
+
if (!srcExists) throw new Error("relative srcpath does not exist");
|
|
1703
|
+
return {
|
|
1704
|
+
toCwd: srcpath,
|
|
1705
|
+
toDst: path2.relative(dstdir, srcpath)
|
|
1706
|
+
};
|
|
1707
|
+
}
|
|
1708
|
+
module.exports = {
|
|
1709
|
+
symlinkPaths: u(symlinkPaths),
|
|
1710
|
+
symlinkPathsSync
|
|
1711
|
+
};
|
|
1712
|
+
}
|
|
1713
|
+
});
|
|
1714
|
+
|
|
1715
|
+
// ../../node_modules/fs-extra/lib/ensure/symlink-type.js
|
|
1716
|
+
var require_symlink_type = __commonJS({
|
|
1717
|
+
"../../node_modules/fs-extra/lib/ensure/symlink-type.js"(exports, module) {
|
|
1718
|
+
"use strict";
|
|
1719
|
+
var fs4 = require_fs();
|
|
1720
|
+
var u = require_universalify().fromPromise;
|
|
1721
|
+
async function symlinkType(srcpath, type) {
|
|
1722
|
+
if (type) return type;
|
|
1723
|
+
let stats;
|
|
1724
|
+
try {
|
|
1725
|
+
stats = await fs4.lstat(srcpath);
|
|
1726
|
+
} catch {
|
|
1727
|
+
return "file";
|
|
1728
|
+
}
|
|
1729
|
+
return stats && stats.isDirectory() ? "dir" : "file";
|
|
1730
|
+
}
|
|
1731
|
+
function symlinkTypeSync(srcpath, type) {
|
|
1732
|
+
if (type) return type;
|
|
1733
|
+
let stats;
|
|
1734
|
+
try {
|
|
1735
|
+
stats = fs4.lstatSync(srcpath);
|
|
1736
|
+
} catch {
|
|
1737
|
+
return "file";
|
|
1738
|
+
}
|
|
1739
|
+
return stats && stats.isDirectory() ? "dir" : "file";
|
|
1740
|
+
}
|
|
1741
|
+
module.exports = {
|
|
1742
|
+
symlinkType: u(symlinkType),
|
|
1743
|
+
symlinkTypeSync
|
|
1744
|
+
};
|
|
1745
|
+
}
|
|
1746
|
+
});
|
|
1747
|
+
|
|
1748
|
+
// ../../node_modules/fs-extra/lib/ensure/symlink.js
|
|
1749
|
+
var require_symlink = __commonJS({
|
|
1750
|
+
"../../node_modules/fs-extra/lib/ensure/symlink.js"(exports, module) {
|
|
1751
|
+
"use strict";
|
|
1752
|
+
var u = require_universalify().fromPromise;
|
|
1753
|
+
var path2 = __require("path");
|
|
1754
|
+
var fs4 = require_fs();
|
|
1755
|
+
var { mkdirs, mkdirsSync } = require_mkdirs();
|
|
1756
|
+
var { symlinkPaths, symlinkPathsSync } = require_symlink_paths();
|
|
1757
|
+
var { symlinkType, symlinkTypeSync } = require_symlink_type();
|
|
1758
|
+
var { pathExists } = require_path_exists();
|
|
1759
|
+
var { areIdentical } = require_stat();
|
|
1760
|
+
async function createSymlink(srcpath, dstpath, type) {
|
|
1761
|
+
let stats;
|
|
1762
|
+
try {
|
|
1763
|
+
stats = await fs4.lstat(dstpath);
|
|
1764
|
+
} catch {
|
|
1765
|
+
}
|
|
1766
|
+
if (stats && stats.isSymbolicLink()) {
|
|
1767
|
+
const [srcStat, dstStat] = await Promise.all([
|
|
1768
|
+
fs4.stat(srcpath),
|
|
1769
|
+
fs4.stat(dstpath)
|
|
1770
|
+
]);
|
|
1771
|
+
if (areIdentical(srcStat, dstStat)) return;
|
|
1772
|
+
}
|
|
1773
|
+
const relative = await symlinkPaths(srcpath, dstpath);
|
|
1774
|
+
srcpath = relative.toDst;
|
|
1775
|
+
const toType = await symlinkType(relative.toCwd, type);
|
|
1776
|
+
const dir = path2.dirname(dstpath);
|
|
1777
|
+
if (!await pathExists(dir)) {
|
|
1778
|
+
await mkdirs(dir);
|
|
1779
|
+
}
|
|
1780
|
+
return fs4.symlink(srcpath, dstpath, toType);
|
|
1781
|
+
}
|
|
1782
|
+
function createSymlinkSync(srcpath, dstpath, type) {
|
|
1783
|
+
let stats;
|
|
1784
|
+
try {
|
|
1785
|
+
stats = fs4.lstatSync(dstpath);
|
|
1786
|
+
} catch {
|
|
1787
|
+
}
|
|
1788
|
+
if (stats && stats.isSymbolicLink()) {
|
|
1789
|
+
const srcStat = fs4.statSync(srcpath);
|
|
1790
|
+
const dstStat = fs4.statSync(dstpath);
|
|
1791
|
+
if (areIdentical(srcStat, dstStat)) return;
|
|
1792
|
+
}
|
|
1793
|
+
const relative = symlinkPathsSync(srcpath, dstpath);
|
|
1794
|
+
srcpath = relative.toDst;
|
|
1795
|
+
type = symlinkTypeSync(relative.toCwd, type);
|
|
1796
|
+
const dir = path2.dirname(dstpath);
|
|
1797
|
+
const exists = fs4.existsSync(dir);
|
|
1798
|
+
if (exists) return fs4.symlinkSync(srcpath, dstpath, type);
|
|
1799
|
+
mkdirsSync(dir);
|
|
1800
|
+
return fs4.symlinkSync(srcpath, dstpath, type);
|
|
1801
|
+
}
|
|
1802
|
+
module.exports = {
|
|
1803
|
+
createSymlink: u(createSymlink),
|
|
1804
|
+
createSymlinkSync
|
|
1805
|
+
};
|
|
1806
|
+
}
|
|
1807
|
+
});
|
|
1808
|
+
|
|
1809
|
+
// ../../node_modules/fs-extra/lib/ensure/index.js
|
|
1810
|
+
var require_ensure = __commonJS({
|
|
1811
|
+
"../../node_modules/fs-extra/lib/ensure/index.js"(exports, module) {
|
|
1812
|
+
"use strict";
|
|
1813
|
+
var { createFile, createFileSync } = require_file();
|
|
1814
|
+
var { createLink, createLinkSync } = require_link();
|
|
1815
|
+
var { createSymlink, createSymlinkSync } = require_symlink();
|
|
1816
|
+
module.exports = {
|
|
1817
|
+
// file
|
|
1818
|
+
createFile,
|
|
1819
|
+
createFileSync,
|
|
1820
|
+
ensureFile: createFile,
|
|
1821
|
+
ensureFileSync: createFileSync,
|
|
1822
|
+
// link
|
|
1823
|
+
createLink,
|
|
1824
|
+
createLinkSync,
|
|
1825
|
+
ensureLink: createLink,
|
|
1826
|
+
ensureLinkSync: createLinkSync,
|
|
1827
|
+
// symlink
|
|
1828
|
+
createSymlink,
|
|
1829
|
+
createSymlinkSync,
|
|
1830
|
+
ensureSymlink: createSymlink,
|
|
1831
|
+
ensureSymlinkSync: createSymlinkSync
|
|
1832
|
+
};
|
|
1833
|
+
}
|
|
1834
|
+
});
|
|
1835
|
+
|
|
1836
|
+
// ../../node_modules/jsonfile/utils.js
|
|
1837
|
+
var require_utils2 = __commonJS({
|
|
1838
|
+
"../../node_modules/jsonfile/utils.js"(exports, module) {
|
|
1839
|
+
"use strict";
|
|
1840
|
+
function stringify(obj, { EOL = "\n", finalEOL = true, replacer = null, spaces } = {}) {
|
|
1841
|
+
const EOF = finalEOL ? EOL : "";
|
|
1842
|
+
const str = JSON.stringify(obj, replacer, spaces);
|
|
1843
|
+
return str.replace(/\n/g, EOL) + EOF;
|
|
1844
|
+
}
|
|
1845
|
+
function stripBom(content) {
|
|
1846
|
+
if (Buffer.isBuffer(content)) content = content.toString("utf8");
|
|
1847
|
+
return content.replace(/^\uFEFF/, "");
|
|
1848
|
+
}
|
|
1849
|
+
module.exports = { stringify, stripBom };
|
|
1850
|
+
}
|
|
1851
|
+
});
|
|
1852
|
+
|
|
1853
|
+
// ../../node_modules/jsonfile/index.js
|
|
1854
|
+
var require_jsonfile = __commonJS({
|
|
1855
|
+
"../../node_modules/jsonfile/index.js"(exports, module) {
|
|
1856
|
+
"use strict";
|
|
1857
|
+
var _fs;
|
|
1858
|
+
try {
|
|
1859
|
+
_fs = require_graceful_fs();
|
|
1860
|
+
} catch (_) {
|
|
1861
|
+
_fs = __require("fs");
|
|
1862
|
+
}
|
|
1863
|
+
var universalify = require_universalify();
|
|
1864
|
+
var { stringify, stripBom } = require_utils2();
|
|
1865
|
+
async function _readFile(file, options = {}) {
|
|
1866
|
+
if (typeof options === "string") {
|
|
1867
|
+
options = { encoding: options };
|
|
1868
|
+
}
|
|
1869
|
+
const fs4 = options.fs || _fs;
|
|
1870
|
+
const shouldThrow = "throws" in options ? options.throws : true;
|
|
1871
|
+
let data = await universalify.fromCallback(fs4.readFile)(file, options);
|
|
1872
|
+
data = stripBom(data);
|
|
1873
|
+
let obj;
|
|
1874
|
+
try {
|
|
1875
|
+
obj = JSON.parse(data, options ? options.reviver : null);
|
|
1876
|
+
} catch (err) {
|
|
1877
|
+
if (shouldThrow) {
|
|
1878
|
+
err.message = `${file}: ${err.message}`;
|
|
1879
|
+
throw err;
|
|
1880
|
+
} else {
|
|
1881
|
+
return null;
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
return obj;
|
|
1885
|
+
}
|
|
1886
|
+
var readFile = universalify.fromPromise(_readFile);
|
|
1887
|
+
function readFileSync(file, options = {}) {
|
|
1888
|
+
if (typeof options === "string") {
|
|
1889
|
+
options = { encoding: options };
|
|
1890
|
+
}
|
|
1891
|
+
const fs4 = options.fs || _fs;
|
|
1892
|
+
const shouldThrow = "throws" in options ? options.throws : true;
|
|
1893
|
+
try {
|
|
1894
|
+
let content = fs4.readFileSync(file, options);
|
|
1895
|
+
content = stripBom(content);
|
|
1896
|
+
return JSON.parse(content, options.reviver);
|
|
1897
|
+
} catch (err) {
|
|
1898
|
+
if (shouldThrow) {
|
|
1899
|
+
err.message = `${file}: ${err.message}`;
|
|
1900
|
+
throw err;
|
|
1901
|
+
} else {
|
|
1902
|
+
return null;
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
async function _writeFile(file, obj, options = {}) {
|
|
1907
|
+
const fs4 = options.fs || _fs;
|
|
1908
|
+
const str = stringify(obj, options);
|
|
1909
|
+
await universalify.fromCallback(fs4.writeFile)(file, str, options);
|
|
1910
|
+
}
|
|
1911
|
+
var writeFile = universalify.fromPromise(_writeFile);
|
|
1912
|
+
function writeFileSync(file, obj, options = {}) {
|
|
1913
|
+
const fs4 = options.fs || _fs;
|
|
1914
|
+
const str = stringify(obj, options);
|
|
1915
|
+
return fs4.writeFileSync(file, str, options);
|
|
1916
|
+
}
|
|
1917
|
+
var jsonfile = {
|
|
1918
|
+
readFile,
|
|
1919
|
+
readFileSync,
|
|
1920
|
+
writeFile,
|
|
1921
|
+
writeFileSync
|
|
1922
|
+
};
|
|
1923
|
+
module.exports = jsonfile;
|
|
1924
|
+
}
|
|
1925
|
+
});
|
|
1926
|
+
|
|
1927
|
+
// ../../node_modules/fs-extra/lib/json/jsonfile.js
|
|
1928
|
+
var require_jsonfile2 = __commonJS({
|
|
1929
|
+
"../../node_modules/fs-extra/lib/json/jsonfile.js"(exports, module) {
|
|
1930
|
+
"use strict";
|
|
1931
|
+
var jsonFile = require_jsonfile();
|
|
1932
|
+
module.exports = {
|
|
1933
|
+
// jsonfile exports
|
|
1934
|
+
readJson: jsonFile.readFile,
|
|
1935
|
+
readJsonSync: jsonFile.readFileSync,
|
|
1936
|
+
writeJson: jsonFile.writeFile,
|
|
1937
|
+
writeJsonSync: jsonFile.writeFileSync
|
|
1938
|
+
};
|
|
1939
|
+
}
|
|
1940
|
+
});
|
|
1941
|
+
|
|
1942
|
+
// ../../node_modules/fs-extra/lib/output-file/index.js
|
|
1943
|
+
var require_output_file = __commonJS({
|
|
1944
|
+
"../../node_modules/fs-extra/lib/output-file/index.js"(exports, module) {
|
|
1945
|
+
"use strict";
|
|
1946
|
+
var u = require_universalify().fromPromise;
|
|
1947
|
+
var fs4 = require_fs();
|
|
1948
|
+
var path2 = __require("path");
|
|
1949
|
+
var mkdir = require_mkdirs();
|
|
1950
|
+
var pathExists = require_path_exists().pathExists;
|
|
1951
|
+
async function outputFile(file, data, encoding = "utf-8") {
|
|
1952
|
+
const dir = path2.dirname(file);
|
|
1953
|
+
if (!await pathExists(dir)) {
|
|
1954
|
+
await mkdir.mkdirs(dir);
|
|
1955
|
+
}
|
|
1956
|
+
return fs4.writeFile(file, data, encoding);
|
|
1957
|
+
}
|
|
1958
|
+
function outputFileSync(file, ...args) {
|
|
1959
|
+
const dir = path2.dirname(file);
|
|
1960
|
+
if (!fs4.existsSync(dir)) {
|
|
1961
|
+
mkdir.mkdirsSync(dir);
|
|
1962
|
+
}
|
|
1963
|
+
fs4.writeFileSync(file, ...args);
|
|
1964
|
+
}
|
|
1965
|
+
module.exports = {
|
|
1966
|
+
outputFile: u(outputFile),
|
|
1967
|
+
outputFileSync
|
|
1968
|
+
};
|
|
1969
|
+
}
|
|
1970
|
+
});
|
|
1971
|
+
|
|
1972
|
+
// ../../node_modules/fs-extra/lib/json/output-json.js
|
|
1973
|
+
var require_output_json = __commonJS({
|
|
1974
|
+
"../../node_modules/fs-extra/lib/json/output-json.js"(exports, module) {
|
|
1975
|
+
"use strict";
|
|
1976
|
+
var { stringify } = require_utils2();
|
|
1977
|
+
var { outputFile } = require_output_file();
|
|
1978
|
+
async function outputJson(file, data, options = {}) {
|
|
1979
|
+
const str = stringify(data, options);
|
|
1980
|
+
await outputFile(file, str, options);
|
|
1981
|
+
}
|
|
1982
|
+
module.exports = outputJson;
|
|
1983
|
+
}
|
|
1984
|
+
});
|
|
1985
|
+
|
|
1986
|
+
// ../../node_modules/fs-extra/lib/json/output-json-sync.js
|
|
1987
|
+
var require_output_json_sync = __commonJS({
|
|
1988
|
+
"../../node_modules/fs-extra/lib/json/output-json-sync.js"(exports, module) {
|
|
1989
|
+
"use strict";
|
|
1990
|
+
var { stringify } = require_utils2();
|
|
1991
|
+
var { outputFileSync } = require_output_file();
|
|
1992
|
+
function outputJsonSync(file, data, options) {
|
|
1993
|
+
const str = stringify(data, options);
|
|
1994
|
+
outputFileSync(file, str, options);
|
|
1995
|
+
}
|
|
1996
|
+
module.exports = outputJsonSync;
|
|
1997
|
+
}
|
|
1998
|
+
});
|
|
1999
|
+
|
|
2000
|
+
// ../../node_modules/fs-extra/lib/json/index.js
|
|
2001
|
+
var require_json = __commonJS({
|
|
2002
|
+
"../../node_modules/fs-extra/lib/json/index.js"(exports, module) {
|
|
2003
|
+
"use strict";
|
|
2004
|
+
var u = require_universalify().fromPromise;
|
|
2005
|
+
var jsonFile = require_jsonfile2();
|
|
2006
|
+
jsonFile.outputJson = u(require_output_json());
|
|
2007
|
+
jsonFile.outputJsonSync = require_output_json_sync();
|
|
2008
|
+
jsonFile.outputJSON = jsonFile.outputJson;
|
|
2009
|
+
jsonFile.outputJSONSync = jsonFile.outputJsonSync;
|
|
2010
|
+
jsonFile.writeJSON = jsonFile.writeJson;
|
|
2011
|
+
jsonFile.writeJSONSync = jsonFile.writeJsonSync;
|
|
2012
|
+
jsonFile.readJSON = jsonFile.readJson;
|
|
2013
|
+
jsonFile.readJSONSync = jsonFile.readJsonSync;
|
|
2014
|
+
module.exports = jsonFile;
|
|
2015
|
+
}
|
|
2016
|
+
});
|
|
2017
|
+
|
|
2018
|
+
// ../../node_modules/fs-extra/lib/move/move.js
|
|
2019
|
+
var require_move = __commonJS({
|
|
2020
|
+
"../../node_modules/fs-extra/lib/move/move.js"(exports, module) {
|
|
2021
|
+
"use strict";
|
|
2022
|
+
var fs4 = require_fs();
|
|
2023
|
+
var path2 = __require("path");
|
|
2024
|
+
var { copy } = require_copy2();
|
|
2025
|
+
var { remove: remove2 } = require_remove();
|
|
2026
|
+
var { mkdirp } = require_mkdirs();
|
|
2027
|
+
var { pathExists } = require_path_exists();
|
|
2028
|
+
var stat = require_stat();
|
|
2029
|
+
async function move(src, dest, opts = {}) {
|
|
2030
|
+
const overwrite = opts.overwrite || opts.clobber || false;
|
|
2031
|
+
const { srcStat, isChangingCase = false } = await stat.checkPaths(src, dest, "move", opts);
|
|
2032
|
+
await stat.checkParentPaths(src, srcStat, dest, "move");
|
|
2033
|
+
const destParent = path2.dirname(dest);
|
|
2034
|
+
const parsedParentPath = path2.parse(destParent);
|
|
2035
|
+
if (parsedParentPath.root !== destParent) {
|
|
2036
|
+
await mkdirp(destParent);
|
|
2037
|
+
}
|
|
2038
|
+
return doRename(src, dest, overwrite, isChangingCase);
|
|
2039
|
+
}
|
|
2040
|
+
async function doRename(src, dest, overwrite, isChangingCase) {
|
|
2041
|
+
if (!isChangingCase) {
|
|
2042
|
+
if (overwrite) {
|
|
2043
|
+
await remove2(dest);
|
|
2044
|
+
} else if (await pathExists(dest)) {
|
|
2045
|
+
throw new Error("dest already exists.");
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
try {
|
|
2049
|
+
await fs4.rename(src, dest);
|
|
2050
|
+
} catch (err) {
|
|
2051
|
+
if (err.code !== "EXDEV") {
|
|
2052
|
+
throw err;
|
|
2053
|
+
}
|
|
2054
|
+
await moveAcrossDevice(src, dest, overwrite);
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
async function moveAcrossDevice(src, dest, overwrite) {
|
|
2058
|
+
const opts = {
|
|
2059
|
+
overwrite,
|
|
2060
|
+
errorOnExist: true,
|
|
2061
|
+
preserveTimestamps: true
|
|
2062
|
+
};
|
|
2063
|
+
await copy(src, dest, opts);
|
|
2064
|
+
return remove2(src);
|
|
2065
|
+
}
|
|
2066
|
+
module.exports = move;
|
|
2067
|
+
}
|
|
2068
|
+
});
|
|
2069
|
+
|
|
2070
|
+
// ../../node_modules/fs-extra/lib/move/move-sync.js
|
|
2071
|
+
var require_move_sync = __commonJS({
|
|
2072
|
+
"../../node_modules/fs-extra/lib/move/move-sync.js"(exports, module) {
|
|
2073
|
+
"use strict";
|
|
2074
|
+
var fs4 = require_graceful_fs();
|
|
2075
|
+
var path2 = __require("path");
|
|
2076
|
+
var copySync = require_copy2().copySync;
|
|
2077
|
+
var removeSync = require_remove().removeSync;
|
|
2078
|
+
var mkdirpSync = require_mkdirs().mkdirpSync;
|
|
2079
|
+
var stat = require_stat();
|
|
2080
|
+
function moveSync(src, dest, opts) {
|
|
2081
|
+
opts = opts || {};
|
|
2082
|
+
const overwrite = opts.overwrite || opts.clobber || false;
|
|
2083
|
+
const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, "move", opts);
|
|
2084
|
+
stat.checkParentPathsSync(src, srcStat, dest, "move");
|
|
2085
|
+
if (!isParentRoot(dest)) mkdirpSync(path2.dirname(dest));
|
|
2086
|
+
return doRename(src, dest, overwrite, isChangingCase);
|
|
2087
|
+
}
|
|
2088
|
+
function isParentRoot(dest) {
|
|
2089
|
+
const parent = path2.dirname(dest);
|
|
2090
|
+
const parsedPath = path2.parse(parent);
|
|
2091
|
+
return parsedPath.root === parent;
|
|
2092
|
+
}
|
|
2093
|
+
function doRename(src, dest, overwrite, isChangingCase) {
|
|
2094
|
+
if (isChangingCase) return rename(src, dest, overwrite);
|
|
2095
|
+
if (overwrite) {
|
|
2096
|
+
removeSync(dest);
|
|
2097
|
+
return rename(src, dest, overwrite);
|
|
2098
|
+
}
|
|
2099
|
+
if (fs4.existsSync(dest)) throw new Error("dest already exists.");
|
|
2100
|
+
return rename(src, dest, overwrite);
|
|
2101
|
+
}
|
|
2102
|
+
function rename(src, dest, overwrite) {
|
|
2103
|
+
try {
|
|
2104
|
+
fs4.renameSync(src, dest);
|
|
2105
|
+
} catch (err) {
|
|
2106
|
+
if (err.code !== "EXDEV") throw err;
|
|
2107
|
+
return moveAcrossDevice(src, dest, overwrite);
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
function moveAcrossDevice(src, dest, overwrite) {
|
|
2111
|
+
const opts = {
|
|
2112
|
+
overwrite,
|
|
2113
|
+
errorOnExist: true,
|
|
2114
|
+
preserveTimestamps: true
|
|
2115
|
+
};
|
|
2116
|
+
copySync(src, dest, opts);
|
|
2117
|
+
return removeSync(src);
|
|
2118
|
+
}
|
|
2119
|
+
module.exports = moveSync;
|
|
2120
|
+
}
|
|
2121
|
+
});
|
|
2122
|
+
|
|
2123
|
+
// ../../node_modules/fs-extra/lib/move/index.js
|
|
2124
|
+
var require_move2 = __commonJS({
|
|
2125
|
+
"../../node_modules/fs-extra/lib/move/index.js"(exports, module) {
|
|
2126
|
+
"use strict";
|
|
2127
|
+
var u = require_universalify().fromPromise;
|
|
2128
|
+
module.exports = {
|
|
2129
|
+
move: u(require_move()),
|
|
2130
|
+
moveSync: require_move_sync()
|
|
2131
|
+
};
|
|
2132
|
+
}
|
|
2133
|
+
});
|
|
2134
|
+
|
|
2135
|
+
// ../../node_modules/fs-extra/lib/index.js
|
|
2136
|
+
var require_lib = __commonJS({
|
|
2137
|
+
"../../node_modules/fs-extra/lib/index.js"(exports, module) {
|
|
2138
|
+
"use strict";
|
|
2139
|
+
module.exports = {
|
|
2140
|
+
// Export promiseified graceful-fs:
|
|
2141
|
+
...require_fs(),
|
|
2142
|
+
// Export extra methods:
|
|
2143
|
+
...require_copy2(),
|
|
2144
|
+
...require_empty(),
|
|
2145
|
+
...require_ensure(),
|
|
2146
|
+
...require_json(),
|
|
2147
|
+
...require_mkdirs(),
|
|
2148
|
+
...require_move2(),
|
|
2149
|
+
...require_output_file(),
|
|
2150
|
+
...require_path_exists(),
|
|
2151
|
+
...require_remove()
|
|
2152
|
+
};
|
|
2153
|
+
}
|
|
2154
|
+
});
|
|
2155
|
+
|
|
2156
|
+
// bin/designsystemet.ts
|
|
2157
|
+
import { Argument, program } from "@commander-js/extra-typings";
|
|
2158
|
+
import chalk5 from "chalk";
|
|
2159
|
+
|
|
2160
|
+
// src/migrations/codemods/css/plugins.ts
|
|
2161
|
+
import * as R from "ramda";
|
|
2162
|
+
import chalk from "chalk";
|
|
2163
|
+
import hash from "object-hash";
|
|
2164
|
+
var printDelete = (text) => console.log(`${chalk.red("Deleted:")} ${text}`.replace(/"|'/g, ""));
|
|
2165
|
+
var deleteMsg = (decl, from) => `${chalk.yellow(from)} @ ${chalk.gray(`${JSON.stringify(decl.source?.input.file)}:${decl.source?.start?.line}:${decl.source?.start?.column}`)}`;
|
|
2166
|
+
var cssClassRename = (dictionary) => ({
|
|
2167
|
+
postcssPlugin: `Renames CSS classes ${hash(dictionary)}`,
|
|
2168
|
+
Rule(rule) {
|
|
2169
|
+
const selector = rule.selector;
|
|
2170
|
+
if (!selector) return;
|
|
2171
|
+
Object.entries(dictionary).forEach(([from, to]) => {
|
|
2172
|
+
if (!selector.includes(from)) return;
|
|
2173
|
+
const newSelector = selector.replace(new RegExp(from, "g"), to);
|
|
2174
|
+
rule.selector = newSelector;
|
|
2175
|
+
});
|
|
2176
|
+
}
|
|
2177
|
+
});
|
|
2178
|
+
var cssVarRename = (dictionary) => ({
|
|
2179
|
+
postcssPlugin: `Replaces CSS variables ${hash(dictionary)}`,
|
|
2180
|
+
Declaration(decl) {
|
|
2181
|
+
const { value, prop: prop2 } = decl;
|
|
2182
|
+
const deleted = /* @__PURE__ */ new Set();
|
|
2183
|
+
Object.entries(dictionary).forEach(([from, to]) => {
|
|
2184
|
+
if (!R.isEmpty(to)) {
|
|
2185
|
+
switch (true) {
|
|
2186
|
+
case R.includes(from, value):
|
|
2187
|
+
to === "[delete]" && deleted.add(deleteMsg(decl, from));
|
|
2188
|
+
decl.value = value.replace(from, to);
|
|
2189
|
+
break;
|
|
2190
|
+
case R.includes(from, prop2):
|
|
2191
|
+
if (decl.variable) {
|
|
2192
|
+
to === "[delete]" && deleted.add(deleteMsg(decl, from));
|
|
2193
|
+
decl.prop = prop2.replace(from, to);
|
|
2194
|
+
break;
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
});
|
|
2199
|
+
if (deleted.size > 0) {
|
|
2200
|
+
Array.from(deleted).forEach(printDelete);
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
});
|
|
2204
|
+
|
|
2205
|
+
// src/migrations/codemods/css/run.ts
|
|
2206
|
+
import fs from "fs";
|
|
2207
|
+
import postcss from "postcss";
|
|
2208
|
+
import glob from "fast-glob";
|
|
2209
|
+
var runCssCodemod = async ({ plugins = [], globPattern = "./**/*.css" }) => {
|
|
2210
|
+
const processor = postcss(plugins);
|
|
2211
|
+
const transform = async () => {
|
|
2212
|
+
const files = await glob(globPattern, { ignore: ["node_modules/**", "dist/**"] });
|
|
2213
|
+
const filePromises = files.map(async (file) => {
|
|
2214
|
+
const contents = fs.readFileSync(file).toString();
|
|
2215
|
+
const result = await processor.process(contents, { from: file });
|
|
2216
|
+
fs.writeFileSync(file, result.css);
|
|
2217
|
+
});
|
|
2218
|
+
await Promise.all(filePromises);
|
|
2219
|
+
};
|
|
2220
|
+
return transform();
|
|
2221
|
+
};
|
|
2222
|
+
|
|
2223
|
+
// src/migrations/beta-to-v1.ts
|
|
2224
|
+
var beta_to_v1_default = (glob4) => runCssCodemod({
|
|
2225
|
+
globPattern: glob4,
|
|
2226
|
+
plugins: [
|
|
2227
|
+
cssClassRename({
|
|
2228
|
+
".fds-": ".ds-"
|
|
2229
|
+
}),
|
|
2230
|
+
// New component token prefixes
|
|
2231
|
+
cssVarRename({
|
|
2232
|
+
"--fds-accordion": "--dsc-accordion",
|
|
2233
|
+
"--fds-alert": "--dsc-alert",
|
|
2234
|
+
"--fds-btn": "--dsc-btn",
|
|
2235
|
+
"--fds-checkbox": "--dsc-checkbox",
|
|
2236
|
+
"--fdsc-chip": "--dsc-chip",
|
|
2237
|
+
"--fdsc-gap": "--dsc-chip-group-gap",
|
|
2238
|
+
"--fdsc-removable": "--dsc-removable",
|
|
2239
|
+
"--fdsc-bottom": "--dsc-bottom",
|
|
2240
|
+
"--fds-pagination": "--dsc-pagination",
|
|
2241
|
+
"--fds-popover": "--dsc-popover",
|
|
2242
|
+
"--fds-radio": "--dsc-radio",
|
|
2243
|
+
"--f-search": "--dsc-search",
|
|
2244
|
+
"--fds-skeleton": "--dsc-skeleton",
|
|
2245
|
+
"--fds-switch--transition": "--dsc-switch-transition",
|
|
2246
|
+
"--fds-switch": "--dsc-switch",
|
|
2247
|
+
"--table-padding": "--dsc-table-padding",
|
|
2248
|
+
"--border-radius": "--dsc-table-border-radius",
|
|
2249
|
+
"--fds-tabs": "--dsc-tabs",
|
|
2250
|
+
"--fds-tag": "--dsc-tag",
|
|
2251
|
+
"--fds-focus-border-width": "--dsc-focus-border-width"
|
|
2252
|
+
}),
|
|
2253
|
+
// New tokens
|
|
2254
|
+
cssVarRename({
|
|
2255
|
+
"--fds-semantic-surface-first-light": "--ds-color-brand1-surface-default",
|
|
2256
|
+
"--fds-semantic-surface-first-light-hover": "--ds-color-brand1-surface-hover",
|
|
2257
|
+
"--fds-semantic-surface-first-light-active": "--ds-color-brand1-surface-active",
|
|
2258
|
+
"--fds-semantic-surface-first-dark": "[delete]",
|
|
2259
|
+
"--fds-semantic-surface-second-light": "--ds-color-brand2-surface-default",
|
|
2260
|
+
"--fds-semantic-surface-second-light-hover": "--ds-color-brand2-surface-hover",
|
|
2261
|
+
"--fds-semantic-surface-second-light-active": "--ds-color-brand2-surface-active",
|
|
2262
|
+
"--fds-semantic-surface-second-dark": "[delete]",
|
|
2263
|
+
"--fds-semantic-surface-third-light": "--ds-color-brand3-surface-default",
|
|
2264
|
+
"--fds-semantic-surface-third-light-hover": "--ds-color-brand3-surface-hover",
|
|
2265
|
+
"--fds-semantic-surface-third-light-active": "--ds-color-brand3-surface-active",
|
|
2266
|
+
"--fds-semantic-surface-third-dark": "[delete]",
|
|
2267
|
+
"--fds-semantic-surface-action-first-subtle": "--ds-color-accent-surface-default",
|
|
2268
|
+
"--fds-semantic-surface-action-first-subtle-hover": "--ds-color-accent-surface-hover",
|
|
2269
|
+
"--fds-semantic-surface-action-first-default": "--ds-color-accent-base-default",
|
|
2270
|
+
"--fds-semantic-surface-action-first-hover": "--ds-color-accent-base-hover",
|
|
2271
|
+
"--fds-semantic-surface-action-first-active": "--ds-color-accent-base-active",
|
|
2272
|
+
"--fds-semantic-surface-action-first-no_fill": "--ds-color-accent-background-default",
|
|
2273
|
+
"--fds-semantic-surface-action-first-no_fill-hover": "--ds-color-accent-surface-default",
|
|
2274
|
+
"--fds-semantic-surface-action-first-no_fill-active": "--ds-color-accent-surface-hover",
|
|
2275
|
+
"--fds-semantic-surface-action-second-subtle": "--ds-color-neutral-surface-default",
|
|
2276
|
+
"--fds-semantic-surface-action-second-subtle-hover": "--ds-color-neutral-surface-hover",
|
|
2277
|
+
"--fds-semantic-surface-action-second-default": "--ds-color-neutral-base-default",
|
|
2278
|
+
"--fds-semantic-surface-action-second-hover": "--ds-color-neutral-base-hover",
|
|
2279
|
+
"--fds-semantic-surface-action-second-active": "--ds-color-neutral-base-active",
|
|
2280
|
+
"--fds-semantic-surface-action-second-no_fill": "--ds-color-neutral-background-default",
|
|
2281
|
+
"--fds-semantic-surface-action-second-no_fill-hover": "--ds-color-neutral-surface-default",
|
|
2282
|
+
"--fds-semantic-surface-action-second-no_fill-active": "--ds-color-neutral-surface-hover",
|
|
2283
|
+
"--fds-semantic-surface-action-subtle": "--ds-color-accent-surface-default",
|
|
2284
|
+
"--fds-semantic-surface-action-subtle-hover": "--ds-color-accent-surface-hover",
|
|
2285
|
+
"--fds-semantic-surface-action-default": "--ds-color-accent-base-default",
|
|
2286
|
+
"--fds-semantic-surface-action-hover": "--ds-color-accent-base-hover",
|
|
2287
|
+
"--fds-semantic-surface-action-active": "--ds-color-accent-base-active",
|
|
2288
|
+
"--fds-semantic-surface-action-no_fill": "--ds-color-accent-background-default",
|
|
2289
|
+
"--fds-semantic-surface-action-no_fill-hover": "--ds-color-accent-surface-default",
|
|
2290
|
+
"--fds-semantic-surface-action-no_fill-active": "--ds-color-accent-surface-hover",
|
|
2291
|
+
"--fds-semantic-surface-action-checked": "--ds-color-accent-base-default",
|
|
2292
|
+
"--fds-semantic-surface-neutral-default": "--ds-color-neutral-background-default",
|
|
2293
|
+
"--fds-semantic-surface-neutral-selected": "[delete]",
|
|
2294
|
+
"--fds-semantic-surface-neutral-subtle": "--ds-color-neutral-background-subtle",
|
|
2295
|
+
"--fds-semantic-surface-neutral-subtle-hover": "--ds-color-neutral-surface-default",
|
|
2296
|
+
"--fds-semantic-surface-neutral-dark": "[delete]",
|
|
2297
|
+
"--fds-semantic-surface-neutral-dark-hover": "[delete]",
|
|
2298
|
+
"--fds-semantic-surface-neutral-inverted": "[delete]",
|
|
2299
|
+
"--fds-semantic-surface-success-subtle": "--ds-color-success-surface-default",
|
|
2300
|
+
"--fds-semantic-surface-success-subtle-hover": "--ds-color-success-surface-hover",
|
|
2301
|
+
"--fds-semantic-surface-success-default": "--ds-color-success-base-default",
|
|
2302
|
+
"--fds-semantic-surface-success-hover": "--ds-color-success-base-hover",
|
|
2303
|
+
"--fds-semantic-surface-success-active": "--ds-color-success-base-active",
|
|
2304
|
+
"--fds-semantic-surface-success-no_fill": "--ds-color-success-background-default",
|
|
2305
|
+
"--fds-semantic-surface-success-no_fill-hover": "--ds-color-success-surface-default",
|
|
2306
|
+
"--fds-semantic-surface-success-no_fill-active": "--ds-color-success-surface-hover",
|
|
2307
|
+
"--fds-semantic-surface-warning-subtle": "--ds-color-warning-surface-default",
|
|
2308
|
+
"--fds-semantic-surface-warning-subtle-hover": "--ds-color-warning-surface-default",
|
|
2309
|
+
"--fds-semantic-surface-warning-default": "--ds-color-warning-surface-default",
|
|
2310
|
+
"--fds-semantic-surface-warning-default-hover": "--ds-color-warning-surface-hover",
|
|
2311
|
+
"--fds-semantic-surface-danger-subtle": "--ds-color-danger-surface-default",
|
|
2312
|
+
"--fds-semantic-surface-danger-subtle-hover": "--ds-color-danger-surface-hover",
|
|
2313
|
+
"--fds-semantic-surface-danger-default": "--ds-color-danger-base-default",
|
|
2314
|
+
"--fds-semantic-surface-danger-hover": "--ds-color-danger-base-hover",
|
|
2315
|
+
"--fds-semantic-surface-danger-active": "--ds-color-danger-base-active",
|
|
2316
|
+
"--fds-semantic-surface-danger-no_fill": "--ds-color-danger-background-default",
|
|
2317
|
+
"--fds-semantic-surface-danger-no_fill-hover": "--ds-color-danger-surface-default",
|
|
2318
|
+
"--fds-semantic-surface-danger-no_fill-active": "--ds-color-danger-surface-hover",
|
|
2319
|
+
"--fds-semantic-surface-info-subtle": "--ds-color-info-surface-default",
|
|
2320
|
+
"--fds-semantic-surface-info-subtle-hover": "[delete]",
|
|
2321
|
+
"--fds-semantic-surface-on_inverted-default": "[delete]",
|
|
2322
|
+
"--fds-semantic-surface-on_inverted-hover": "[delete]",
|
|
2323
|
+
"--fds-semantic-surface-on_inverted-active": "[delete]",
|
|
2324
|
+
"--fds-semantic-surface-on_inverted-no_fill": "[delete]",
|
|
2325
|
+
"--fds-semantic-surface-on_inverted-no_fill-hover": "[delete]",
|
|
2326
|
+
"--fds-semantic-surface-on_inverted-no_fill-active": "[delete]",
|
|
2327
|
+
"--fds-semantic-surface-focus-default": "[delete]",
|
|
2328
|
+
"--fds-semantic-border-first-default": "--ds-color-brand1-base-default",
|
|
2329
|
+
"--fds-semantic-border-first-hover": "--ds-color-brand1-base-hover",
|
|
2330
|
+
"--fds-semantic-border-first-active": "--ds-color-brand1-base-active",
|
|
2331
|
+
"--fds-semantic-border-second-default": "--ds-color-brand2-base-default",
|
|
2332
|
+
"--fds-semantic-border-second-hover": "--ds-color-brand2-base-hover",
|
|
2333
|
+
"--fds-semantic-border-second-active": "--ds-color-brand2-base-active",
|
|
2334
|
+
"--fds-semantic-border-third-default": "--ds-color-brand3-base-default",
|
|
2335
|
+
"--fds-semantic-border-third-hover": "--ds-color-brand3-base-hover",
|
|
2336
|
+
"--fds-semantic-border-third-active": "--ds-color-brand3-base-active",
|
|
2337
|
+
"--fds-semantic-border-action-first-subtle": "--ds-color-accent-border-subtle",
|
|
2338
|
+
"--fds-semantic-border-action-first-subtle-hover": "--ds-color-accent-border-default",
|
|
2339
|
+
"--fds-semantic-border-action-first-default": "--ds-color-accent-base-default",
|
|
2340
|
+
"--fds-semantic-border-action-first-hover": "--ds-color-accent-base-hover",
|
|
2341
|
+
"--fds-semantic-border-action-first-active": "--ds-color-accent-base-active",
|
|
2342
|
+
"--fds-semantic-border-action-second-subtle": "--ds-color-neutral-border-subtle",
|
|
2343
|
+
"--fds-semantic-border-action-second-subtle-hover": "--ds-color-neutral-border-default",
|
|
2344
|
+
"--fds-semantic-border-action-second-default": "--ds-color-neutral-base-default",
|
|
2345
|
+
"--fds-semantic-border-action-second-hover": "--ds-color-neutral-base-hover",
|
|
2346
|
+
"--fds-semantic-border-action-second-active": "--ds-color-neutral-base-active",
|
|
2347
|
+
"--fds-semantic-border-action-subtle": "--ds-color-accent-border-subtle",
|
|
2348
|
+
"--fds-semantic-border-action-subtle-hover": "--ds-color-accent-border-default",
|
|
2349
|
+
"--fds-semantic-border-action-default": "--ds-color-accent-base-default",
|
|
2350
|
+
"--fds-semantic-border-action-hover": "--ds-color-accent-base-hover",
|
|
2351
|
+
"--fds-semantic-border-action-active": "--ds-color-accent-base-active",
|
|
2352
|
+
"--fds-semantic-border-action-dark": "[delete]",
|
|
2353
|
+
"--fds-semantic-border-action-dark-hover": "[delete]",
|
|
2354
|
+
"--fds-semantic-border-info-default": "--ds-color-info-border-strong",
|
|
2355
|
+
"--fds-semantic-border-neutral-default": "--ds-color-neutral-border-strong",
|
|
2356
|
+
"--fds-semantic-border-neutral-subtle": "--ds-color-neutral-border-subtle",
|
|
2357
|
+
"--fds-semantic-border-neutral-strong": "--ds-color-neutral-base-default",
|
|
2358
|
+
"--fds-semantic-border-success-default": "--ds-color-success-border-default",
|
|
2359
|
+
"--fds-semantic-border-success-hover": "[delete]",
|
|
2360
|
+
"--fds-semantic-border-success-active": "[delete]",
|
|
2361
|
+
"--fds-semantic-border-warning-default": "--ds-color-warning-border-default",
|
|
2362
|
+
"--fds-semantic-border-warning-hover": "[delete]",
|
|
2363
|
+
"--fds-semantic-border-warning-active": "[delete]",
|
|
2364
|
+
"--fds-semantic-border-danger-default": "--ds-color-danger-border-default",
|
|
2365
|
+
"--fds-semantic-border-danger-hover": "--ds-color-danger-border-strong",
|
|
2366
|
+
"--fds-semantic-border-danger-active": "--ds-color-danger-border-strong",
|
|
2367
|
+
"--fds-semantic-border-focus-outline": "--ds-color-neutral-text-default",
|
|
2368
|
+
"--fds-semantic-border-focus-boxshadow": "--ds-color-neutral-background-default",
|
|
2369
|
+
"--fds-semantic-border-on_inverted-default": "[delete]",
|
|
2370
|
+
"--fds-semantic-border-input-default": "--ds-color-neutral-border-default",
|
|
2371
|
+
"--fds-semantic-border-input-hover": "--ds-color-accent-border-strong",
|
|
2372
|
+
"--fds-semantic-border-divider-default": "--ds-color-neutral-border-subtle",
|
|
2373
|
+
"--fds-semantic-border-divider-subtle": "--ds-color-neutral-border-subtle",
|
|
2374
|
+
"--fds-semantic-border-divider-strong": "--ds-color-neutral-border-default",
|
|
2375
|
+
"--fds-semantic-text-action-first-default": "--ds-color-accent-base-default",
|
|
2376
|
+
"--fds-semantic-text-action-first-hover": "--ds-color-accent-base-hover",
|
|
2377
|
+
"--fds-semantic-text-action-first-active": "--ds-color-accent-base-active",
|
|
2378
|
+
"--fds-semantic-text-action-first-on_action": "--ds-color-accent-contrast-default",
|
|
2379
|
+
"--fds-semantic-text-action-second-default": "--ds-color-neutral-base-default",
|
|
2380
|
+
"--fds-semantic-text-action-second-hover": "--ds-color-neutral-base-hover",
|
|
2381
|
+
"--fds-semantic-text-action-second-active": "--ds-color-neutral-base-active",
|
|
2382
|
+
"--fds-semantic-text-action-second-on_action": "--ds-color-neutral-contrast-default",
|
|
2383
|
+
"--fds-semantic-text-action-default": "--ds-color-accent-base-default",
|
|
2384
|
+
"--fds-semantic-text-action-hover": "--ds-color-accent-base-hover",
|
|
2385
|
+
"--fds-semantic-text-action-active": "--ds-color-accent-base-active",
|
|
2386
|
+
"--fds-semantic-text-action-on_action": "--ds-color-accent-contrast-default",
|
|
2387
|
+
"--fds-semantic-text-success-default": "--ds-color-success-base-default",
|
|
2388
|
+
"--fds-semantic-text-success-hover": "--ds-color-success-base-default",
|
|
2389
|
+
"--fds-semantic-text-success-active": "--ds-color-success-base-default",
|
|
2390
|
+
"--fds-semantic-text-success-on_success": "--ds-color-success-contrast-default",
|
|
2391
|
+
"--fds-semantic-text-success-on_success_subtle": "--ds-color-success-text-default",
|
|
2392
|
+
"--fds-semantic-text-neutral-default": "--ds-color-neutral-text-default",
|
|
2393
|
+
"--fds-semantic-text-neutral-subtle": "--ds-color-neutral-text-subtle",
|
|
2394
|
+
"--fds-semantic-text-neutral-on_inverted": "--ds-color-neutral-contrast-default",
|
|
2395
|
+
"--fds-semantic-text-warning-default": "[delete]",
|
|
2396
|
+
"--fds-semantic-text-warning-icon_warning": "--ds-color-warning-base-default",
|
|
2397
|
+
"--fds-semantic-text-warning-on_warning": "--ds-color-neutral-text-default",
|
|
2398
|
+
"--fds-semantic-text-danger-default": "--ds-color-danger-text-default",
|
|
2399
|
+
"--fds-semantic-text-danger-hover": "--ds-color-danger-text-default",
|
|
2400
|
+
"--fds-semantic-text-danger-active": "--ds-color-danger-text-default",
|
|
2401
|
+
"--fds-semantic-text-danger-on_danger": "--ds-color-danger-contrast-default",
|
|
2402
|
+
"--fds-semantic-text-danger-on_danger_subtle": "--ds-color-danger-text-default",
|
|
2403
|
+
"--fds-semantic-text-visited-default": "--ds-global-purple-13",
|
|
2404
|
+
"--fds-semantic-background-default": "--ds-color-neutral-background-default",
|
|
2405
|
+
"--fds-semantic-background-subtle": "--ds-color-neutral-background-subtle",
|
|
2406
|
+
"--fds-typography-heading-3xlarge": "[delete]",
|
|
2407
|
+
"--fds-typography-heading-2xlarge": "--ds-typography-heading-2xl",
|
|
2408
|
+
"--fds-typography-heading-xlarge": "--ds-typography-heading-xl",
|
|
2409
|
+
"--fds-typography-heading-large": "--ds-typography-heading-lg",
|
|
2410
|
+
"--fds-typography-heading-medium": "--ds-typography-heading-md",
|
|
2411
|
+
"--fds-typography-heading-small": "--ds-typography-heading-sm",
|
|
2412
|
+
"--fds-typography-heading-xsmall": "--ds-typography-heading-xs",
|
|
2413
|
+
"--fds-typography-heading-xxsmall": "--ds-typography-heading-2xs",
|
|
2414
|
+
"--fds-typography-ingress-large": "--ds-typography-ingress-lg",
|
|
2415
|
+
"--fds-typography-ingress-medium": "--ds-typography-ingress-md",
|
|
2416
|
+
"--fds-typography-ingress-small": "--ds-typography-ingress-sm",
|
|
2417
|
+
"--fds-typography-ingress-xsmall": "--ds-typography-ingress-xs",
|
|
2418
|
+
"--fds-typography-paragraph-large": "--ds-typography-paragraph-lg",
|
|
2419
|
+
"--fds-typography-paragraph-medium": "--ds-typography-paragraph-md",
|
|
2420
|
+
"--fds-typography-paragraph-small": "--ds-typography-paragraph-sm",
|
|
2421
|
+
"--fds-typography-paragraph-xsmall": "--ds-typography-paragraph-xs",
|
|
2422
|
+
"--fds-typography-paragraph-short-large": "--ds-typography-paragraph-short-lg",
|
|
2423
|
+
"--fds-typography-paragraph-short-medium": "--ds-typography-paragraph-short-md",
|
|
2424
|
+
"--fds-typography-paragraph-short-small": "--ds-typography-paragraph-short-sm",
|
|
2425
|
+
"--fds-typography-paragraph-short-xsmall": "--ds-typography-paragraph-short-xs",
|
|
2426
|
+
"--fds-typography-paragraph-long-large": "--ds-typography-paragraph-long-lg",
|
|
2427
|
+
"--fds-typography-paragraph-long-medium": "--ds-typography-paragraph-long-md",
|
|
2428
|
+
"--fds-typography-paragraph-long-small": "--ds-typography-paragraph-long-sm",
|
|
2429
|
+
"--fds-typography-paragraph-long-xsmall": "--ds-typography-paragraph-long-xs",
|
|
2430
|
+
"--fds-typography-label-large": "--ds-typography-label-lg",
|
|
2431
|
+
"--fds-typography-label-medium": "--ds-typography-label-md",
|
|
2432
|
+
"--fds-typography-label-small": "--ds-typography-label-sm",
|
|
2433
|
+
"--fds-typography-label-xsmall": "--ds-typography-label-xs",
|
|
2434
|
+
"--fds-typography-error_message-large": "--ds-typography-error_message-lg",
|
|
2435
|
+
"--fds-typography-error_message-medium": "--ds-typography-error_message-md",
|
|
2436
|
+
"--fds-typography-error_message-small": "--ds-typography-error_message-sm",
|
|
2437
|
+
"--fds-typography-error_message-xsmall": "--ds-typography-error_message-xs",
|
|
2438
|
+
"--fds-typography-interactive-large": "--ds-typography-paragraph-short-lg",
|
|
2439
|
+
"--fds-typography-interactive-medium": "--ds-typography-paragraph-short-md",
|
|
2440
|
+
"--fds-typography-interactive-small": "--ds-typography-paragraph-short-sm",
|
|
2441
|
+
"--fds-border_radius-interactive": "--ds-border-radius-md",
|
|
2442
|
+
"--fds-border_radius-small": "--ds-border-radius-sm",
|
|
2443
|
+
"--fds-border_radius-medium": "--ds-border-radius-md",
|
|
2444
|
+
"--fds-border_radius-large": "--ds-border-radius-lg",
|
|
2445
|
+
"--fds-border_radius-xlarge": "--ds-border-radius-xl",
|
|
2446
|
+
"--fds-border_radius-xxlarge": "--ds-border-radius-2xl",
|
|
2447
|
+
"--fds-border_radius-xxxlarge": "--ds-border-radius-3xl",
|
|
2448
|
+
"--fds-border_radius-xxxxlarge": "--ds-border-radius-4xl",
|
|
2449
|
+
"--fds-border_radius-full": "--ds-border-radius-full",
|
|
2450
|
+
"--fds-base_spacing": "[delete]",
|
|
2451
|
+
"--fds-base_sizing": "[delete]",
|
|
2452
|
+
"--fds-border_width-default": "--ds-border-width-default",
|
|
2453
|
+
"--fds-border_width-active": "--ds-border-width-highlight",
|
|
2454
|
+
"--fds-border_width-tab_focus": "--ds-border-width-highlight",
|
|
2455
|
+
"--fds-shadow-xsmall": "--ds-shadow-xs",
|
|
2456
|
+
"--fds-shadow-small": "--ds-shadow-sm",
|
|
2457
|
+
"--fds-shadow-medium": "--ds-shadow-md",
|
|
2458
|
+
"--fds-shadow-large": "--ds-shadow-lg",
|
|
2459
|
+
"--fds-shadow-xlarge": "--ds-shadow-xl",
|
|
2460
|
+
"--fds-spacing-0": "--ds-spacing-0",
|
|
2461
|
+
"--fds-spacing-1": "--ds-spacing-1",
|
|
2462
|
+
"--fds-spacing-2": "--ds-spacing-2",
|
|
2463
|
+
"--fds-spacing-3": "--ds-spacing-3",
|
|
2464
|
+
"--fds-spacing-4": "--ds-spacing-4",
|
|
2465
|
+
"--fds-spacing-5": "--ds-spacing-5",
|
|
2466
|
+
"--fds-spacing-6": "--ds-spacing-6",
|
|
2467
|
+
"--fds-spacing-7": "--ds-spacing-7",
|
|
2468
|
+
"--fds-spacing-8": "--ds-spacing-8",
|
|
2469
|
+
"--fds-spacing-9": "--ds-spacing-9",
|
|
2470
|
+
"--fds-spacing-10": "--ds-spacing-10",
|
|
2471
|
+
"--fds-spacing-11": "--ds-spacing-11",
|
|
2472
|
+
"--fds-spacing-12": "--ds-spacing-12",
|
|
2473
|
+
"--fds-spacing-13": "--ds-spacing-13",
|
|
2474
|
+
"--fds-spacing-14": "--ds-spacing-14",
|
|
2475
|
+
"--fds-spacing-15": "--ds-spacing-15",
|
|
2476
|
+
"--fds-spacing-18": "--ds-spacing-18",
|
|
2477
|
+
"--fds-spacing-22": "--ds-spacing-22",
|
|
2478
|
+
"--fds-spacing-26": "--ds-spacing-26",
|
|
2479
|
+
"--fds-spacing-30": "--ds-spacing-30",
|
|
2480
|
+
"--fds-sizing-0": "--ds-sizing-0",
|
|
2481
|
+
"--fds-sizing-1": "--ds-sizing-1",
|
|
2482
|
+
"--fds-sizing-2": "--ds-sizing-2",
|
|
2483
|
+
"--fds-sizing-3": "--ds-sizing-3",
|
|
2484
|
+
"--fds-sizing-4": "--ds-sizing-4",
|
|
2485
|
+
"--fds-sizing-5": "--ds-sizing-5",
|
|
2486
|
+
"--fds-sizing-6": "--ds-sizing-6",
|
|
2487
|
+
"--fds-sizing-7": "--ds-sizing-7",
|
|
2488
|
+
"--fds-sizing-8": "--ds-sizing-8",
|
|
2489
|
+
"--fds-sizing-9": "--ds-sizing-9",
|
|
2490
|
+
"--fds-sizing-10": "--ds-sizing-10",
|
|
2491
|
+
"--fds-sizing-11": "--ds-sizing-11",
|
|
2492
|
+
"--fds-sizing-12": "--ds-sizing-12",
|
|
2493
|
+
"--fds-sizing-13": "--ds-sizing-13",
|
|
2494
|
+
"--fds-sizing-14": "--ds-sizing-14",
|
|
2495
|
+
"--fds-sizing-15": "--ds-sizing-15",
|
|
2496
|
+
"--fds-sizing-18": "--ds-sizing-18",
|
|
2497
|
+
"--fds-sizing-22": "--ds-sizing-22",
|
|
2498
|
+
"--fds-sizing-26": "--ds-sizing-26",
|
|
2499
|
+
"--fds-sizing-30": "--ds-sizing-30",
|
|
2500
|
+
"--fds-opacity-disabled": "--ds-disabled-opacity",
|
|
2501
|
+
"--fds-colors-blue-100": "--ds-global-blue-1",
|
|
2502
|
+
"--fds-colors-blue-200": "--ds-global-blue-2",
|
|
2503
|
+
"--fds-colors-blue-700": "--ds-global-blue-7",
|
|
2504
|
+
"--fds-colors-blue-800": "--ds-global-blue-8",
|
|
2505
|
+
"--fds-colors-blue-900": "--ds-global-blue-9",
|
|
2506
|
+
"--fds-colors-grey-100": "--ds-color-neutral-1",
|
|
2507
|
+
"--fds-colors-grey-200": "--ds-color-neutral-2",
|
|
2508
|
+
"--fds-colors-grey-400": "--ds-color-neutral-4",
|
|
2509
|
+
"--fds-colors-grey-600": "--ds-color-neutral-6",
|
|
2510
|
+
"--fds-colors-grey-700": "--ds-color-neutral-7",
|
|
2511
|
+
"--fds-colors-grey-800": "--ds-color-neutral-8",
|
|
2512
|
+
"--fds-colors-green-200": "--ds-global-green-2",
|
|
2513
|
+
"--fds-colors-green-300": "--ds-global-green-3",
|
|
2514
|
+
"--fds-colors-green-700": "--ds-global-green-7",
|
|
2515
|
+
"--fds-colors-green-800": "--ds-global-green-8",
|
|
2516
|
+
"--fds-colors-green-900": "--ds-global-green-9",
|
|
2517
|
+
"--fds-colors-yellow-100": "--ds-global-yellow-1",
|
|
2518
|
+
"--fds-colors-yellow-200": "--ds-global-yellow-2",
|
|
2519
|
+
"--fds-colors-yellow-300": "--ds-global-yellow-3",
|
|
2520
|
+
"--fds-colors-yellow-500": "--ds-global-yellow-5",
|
|
2521
|
+
"--fds-colors-blue-400": "--ds-global-blue-4",
|
|
2522
|
+
"--fds-colors-grey-300": "--ds-global-grey-3",
|
|
2523
|
+
"--fds-colors-orange-600": "--ds-global-orange-6",
|
|
2524
|
+
"--fds-colors-orange-700": "--ds-global-orange-7",
|
|
2525
|
+
"--fds-colors-orange-800": "--ds-global-orange-8",
|
|
2526
|
+
"--fds-colors-red-800": "--ds-global-red-8",
|
|
2527
|
+
"--fds-colors-purple-700": "--ds-global-purple-7",
|
|
2528
|
+
"--fds-colors-red-100": "--ds-global-red-1",
|
|
2529
|
+
"--fds-colors-red-200": "--ds-global-red-2",
|
|
2530
|
+
"--fds-colors-red-500": "--ds-global-red-5",
|
|
2531
|
+
"--fds-colors-red-600": "--ds-global-red-6",
|
|
2532
|
+
"--fds-colors-red-700": "--ds-global-red-7",
|
|
2533
|
+
"--fds-brand-alt1-100": "--ds-color-brand1-1",
|
|
2534
|
+
"--fds-brand-alt1-200": "--ds-color-brand1-2",
|
|
2535
|
+
"--fds-brand-alt1-300": "--ds-color-brand1-3",
|
|
2536
|
+
"--fds-brand-alt1-400": "--ds-color-brand1-4",
|
|
2537
|
+
"--fds-brand-alt1-500": "--ds-color-brand1-5",
|
|
2538
|
+
"--fds-brand-alt1-600": "--ds-color-brand1-6",
|
|
2539
|
+
"--fds-brand-alt1-700": "--ds-color-brand1-7",
|
|
2540
|
+
"--fds-brand-alt1-800": "--ds-color-brand1-8",
|
|
2541
|
+
"--fds-brand-alt1-900": "--ds-color-brand1-9",
|
|
2542
|
+
"--fds-brand-alt2-100": "--ds-color-brand2-1",
|
|
2543
|
+
"--fds-brand-alt2-200": "--ds-color-brand2-2",
|
|
2544
|
+
"--fds-brand-alt2-300": "--ds-color-brand2-3",
|
|
2545
|
+
"--fds-brand-alt2-400": "--ds-color-brand2-4",
|
|
2546
|
+
"--fds-brand-alt2-500": "--ds-color-brand2-5",
|
|
2547
|
+
"--fds-brand-alt2-600": "--ds-color-brand2-6",
|
|
2548
|
+
"--fds-brand-alt2-700": "--ds-color-brand2-7",
|
|
2549
|
+
"--fds-brand-alt2-800": "--ds-color-brand2-8",
|
|
2550
|
+
"--fds-brand-alt2-900": "--ds-color-brand2-9",
|
|
2551
|
+
"--fds-brand-alt3-100": "--ds-color-brand3-1",
|
|
2552
|
+
"--fds-brand-alt3-200": "--ds-color-brand3-2",
|
|
2553
|
+
"--fds-brand-alt3-300": "--ds-color-brand3-3",
|
|
2554
|
+
"--fds-brand-alt3-400": "--ds-color-brand3-4",
|
|
2555
|
+
"--fds-brand-alt3-500": "--ds-color-brand3-5",
|
|
2556
|
+
"--fds-brand-alt3-600": "--ds-color-brand3-6",
|
|
2557
|
+
"--fds-brand-alt3-700": "--ds-color-brand3-7",
|
|
2558
|
+
"--fds-brand-alt3-800": "--ds-color-brand3-8",
|
|
2559
|
+
"--fds-brand-alt3-900": "--ds-color-brand3-9"
|
|
2560
|
+
})
|
|
2561
|
+
]
|
|
2562
|
+
});
|
|
2563
|
+
|
|
2564
|
+
// src/migrations/codemods/jsx/run.ts
|
|
2565
|
+
import glob2 from "fast-glob";
|
|
2566
|
+
import { run as jscodeshift } from "jscodeshift/src/Runner.js";
|
|
2567
|
+
import chalk2 from "chalk";
|
|
2568
|
+
var transformer = `${import.meta.dirname}/classname-prefix.ts`;
|
|
2569
|
+
var runJSXCodemod = async ({ globPattern = "./**/*.tsx", dry }) => {
|
|
2570
|
+
const options = {
|
|
2571
|
+
dry,
|
|
2572
|
+
extensions: "tsx",
|
|
2573
|
+
parser: "tsx"
|
|
2574
|
+
};
|
|
2575
|
+
const transform = async () => {
|
|
2576
|
+
const files = await glob2(globPattern, { ignore: ["node_modules/**", "dist/**"] });
|
|
2577
|
+
const result = await jscodeshift(transformer, files, options);
|
|
2578
|
+
if (result.ok) {
|
|
2579
|
+
console.log(chalk2.green("Finished parsing"));
|
|
2580
|
+
}
|
|
2581
|
+
};
|
|
2582
|
+
return transform();
|
|
2583
|
+
};
|
|
2584
|
+
|
|
2585
|
+
// src/migrations/react-beta-to-v1.ts
|
|
2586
|
+
var react_beta_to_v1_default = (glob4) => runJSXCodemod({ globPattern: glob4 });
|
|
2587
|
+
|
|
2588
|
+
// src/migrations/index.ts
|
|
2589
|
+
var migrations_default = {
|
|
2590
|
+
"css-beta-to-v1": beta_to_v1_default,
|
|
2591
|
+
"react-beta-to-v1": react_beta_to_v1_default
|
|
2592
|
+
};
|
|
2593
|
+
|
|
2594
|
+
// src/tokens/build.ts
|
|
2595
|
+
import path from "path";
|
|
2596
|
+
import fs3 from "fs";
|
|
2597
|
+
import StyleDictionary2 from "style-dictionary";
|
|
2598
|
+
import * as R9 from "ramda";
|
|
2599
|
+
import chalk4 from "chalk";
|
|
2600
|
+
|
|
2601
|
+
// src/tokens/configs.ts
|
|
2602
|
+
var configs_exports = {};
|
|
2603
|
+
__export(configs_exports, {
|
|
2604
|
+
basePxFontSize: () => basePxFontSize,
|
|
2605
|
+
colorModeVariables: () => colorModeVariables,
|
|
2606
|
+
getConfigs: () => getConfigs,
|
|
2607
|
+
permutateThemes: () => permutateThemes2,
|
|
2608
|
+
prefix: () => prefix,
|
|
2609
|
+
semanticVariables: () => semanticVariables,
|
|
2610
|
+
separator: () => separator,
|
|
2611
|
+
typescriptTokens: () => typescriptTokens,
|
|
2612
|
+
typographyCSS: () => typographyCSS
|
|
2613
|
+
});
|
|
2614
|
+
import * as tokenStudio from "@tokens-studio/sd-transforms";
|
|
2615
|
+
import StyleDictionary from "style-dictionary";
|
|
2616
|
+
import { outputReferencesFilter } from "style-dictionary/utils";
|
|
2617
|
+
import * as R8 from "ramda";
|
|
2618
|
+
|
|
2619
|
+
// src/tokens/utils/permutateThemes.ts
|
|
2620
|
+
import * as R2 from "ramda";
|
|
2621
|
+
|
|
2622
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
|
|
2623
|
+
var BoxShadowTypes;
|
|
2624
|
+
(function(BoxShadowTypes2) {
|
|
2625
|
+
BoxShadowTypes2["DROP_SHADOW"] = "dropShadow";
|
|
2626
|
+
BoxShadowTypes2["INNER_SHADOW"] = "innerShadow";
|
|
2627
|
+
})(BoxShadowTypes || (BoxShadowTypes = {}));
|
|
2628
|
+
|
|
2629
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js
|
|
2630
|
+
var ColorModifierTypes;
|
|
2631
|
+
(function(ColorModifierTypes2) {
|
|
2632
|
+
ColorModifierTypes2["LIGHTEN"] = "lighten";
|
|
2633
|
+
ColorModifierTypes2["DARKEN"] = "darken";
|
|
2634
|
+
ColorModifierTypes2["MIX"] = "mix";
|
|
2635
|
+
ColorModifierTypes2["ALPHA"] = "alpha";
|
|
2636
|
+
})(ColorModifierTypes || (ColorModifierTypes = {}));
|
|
2637
|
+
|
|
2638
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js
|
|
2639
|
+
var ColorSpaceTypes;
|
|
2640
|
+
(function(ColorSpaceTypes2) {
|
|
2641
|
+
ColorSpaceTypes2["LCH"] = "lch";
|
|
2642
|
+
ColorSpaceTypes2["SRGB"] = "srgb";
|
|
2643
|
+
ColorSpaceTypes2["P3"] = "p3";
|
|
2644
|
+
ColorSpaceTypes2["HSL"] = "hsl";
|
|
2645
|
+
})(ColorSpaceTypes || (ColorSpaceTypes = {}));
|
|
2646
|
+
|
|
2647
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/Properties.js
|
|
2648
|
+
var Properties;
|
|
2649
|
+
(function(Properties2) {
|
|
2650
|
+
Properties2["sizing"] = "sizing";
|
|
2651
|
+
Properties2["height"] = "height";
|
|
2652
|
+
Properties2["width"] = "width";
|
|
2653
|
+
Properties2["spacing"] = "spacing";
|
|
2654
|
+
Properties2["verticalPadding"] = "verticalPadding";
|
|
2655
|
+
Properties2["horizontalPadding"] = "horizontalPadding";
|
|
2656
|
+
Properties2["paddingTop"] = "paddingTop";
|
|
2657
|
+
Properties2["paddingRight"] = "paddingRight";
|
|
2658
|
+
Properties2["paddingBottom"] = "paddingBottom";
|
|
2659
|
+
Properties2["paddingLeft"] = "paddingLeft";
|
|
2660
|
+
Properties2["itemSpacing"] = "itemSpacing";
|
|
2661
|
+
Properties2["fill"] = "fill";
|
|
2662
|
+
Properties2["backgroundBlur"] = "backgroundBlur";
|
|
2663
|
+
Properties2["border"] = "border";
|
|
2664
|
+
Properties2["borderTop"] = "borderTop";
|
|
2665
|
+
Properties2["borderRight"] = "borderRight";
|
|
2666
|
+
Properties2["borderBottom"] = "borderBottom";
|
|
2667
|
+
Properties2["borderLeft"] = "borderLeft";
|
|
2668
|
+
Properties2["borderColor"] = "borderColor";
|
|
2669
|
+
Properties2["borderRadius"] = "borderRadius";
|
|
2670
|
+
Properties2["borderRadiusTopLeft"] = "borderRadiusTopLeft";
|
|
2671
|
+
Properties2["borderRadiusTopRight"] = "borderRadiusTopRight";
|
|
2672
|
+
Properties2["borderRadiusBottomRight"] = "borderRadiusBottomRight";
|
|
2673
|
+
Properties2["borderRadiusBottomLeft"] = "borderRadiusBottomLeft";
|
|
2674
|
+
Properties2["borderWidth"] = "borderWidth";
|
|
2675
|
+
Properties2["borderWidthTop"] = "borderWidthTop";
|
|
2676
|
+
Properties2["borderWidthRight"] = "borderWidthRight";
|
|
2677
|
+
Properties2["borderWidthBottom"] = "borderWidthBottom";
|
|
2678
|
+
Properties2["borderWidthLeft"] = "borderWidthLeft";
|
|
2679
|
+
Properties2["boxShadow"] = "boxShadow";
|
|
2680
|
+
Properties2["opacity"] = "opacity";
|
|
2681
|
+
Properties2["fontFamilies"] = "fontFamilies";
|
|
2682
|
+
Properties2["fontWeights"] = "fontWeights";
|
|
2683
|
+
Properties2["fontSizes"] = "fontSizes";
|
|
2684
|
+
Properties2["lineHeights"] = "lineHeights";
|
|
2685
|
+
Properties2["typography"] = "typography";
|
|
2686
|
+
Properties2["composition"] = "composition";
|
|
2687
|
+
Properties2["letterSpacing"] = "letterSpacing";
|
|
2688
|
+
Properties2["paragraphSpacing"] = "paragraphSpacing";
|
|
2689
|
+
Properties2["textCase"] = "textCase";
|
|
2690
|
+
Properties2["dimension"] = "dimension";
|
|
2691
|
+
Properties2["textDecoration"] = "textDecoration";
|
|
2692
|
+
Properties2["asset"] = "asset";
|
|
2693
|
+
Properties2["tokenValue"] = "tokenValue";
|
|
2694
|
+
Properties2["value"] = "value";
|
|
2695
|
+
Properties2["tokenName"] = "tokenName";
|
|
2696
|
+
Properties2["description"] = "description";
|
|
2697
|
+
})(Properties || (Properties = {}));
|
|
2698
|
+
|
|
2699
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js
|
|
2700
|
+
var TokenSetStatus;
|
|
2701
|
+
(function(TokenSetStatus2) {
|
|
2702
|
+
TokenSetStatus2["DISABLED"] = "disabled";
|
|
2703
|
+
TokenSetStatus2["SOURCE"] = "source";
|
|
2704
|
+
TokenSetStatus2["ENABLED"] = "enabled";
|
|
2705
|
+
})(TokenSetStatus || (TokenSetStatus = {}));
|
|
2706
|
+
|
|
2707
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/TokenTypes.js
|
|
2708
|
+
var TokenTypes;
|
|
2709
|
+
(function(TokenTypes2) {
|
|
2710
|
+
TokenTypes2["OTHER"] = "other";
|
|
2711
|
+
TokenTypes2["COLOR"] = "color";
|
|
2712
|
+
TokenTypes2["BORDER_RADIUS"] = "borderRadius";
|
|
2713
|
+
TokenTypes2["SIZING"] = "sizing";
|
|
2714
|
+
TokenTypes2["SPACING"] = "spacing";
|
|
2715
|
+
TokenTypes2["TEXT"] = "text";
|
|
2716
|
+
TokenTypes2["TYPOGRAPHY"] = "typography";
|
|
2717
|
+
TokenTypes2["OPACITY"] = "opacity";
|
|
2718
|
+
TokenTypes2["BORDER_WIDTH"] = "borderWidth";
|
|
2719
|
+
TokenTypes2["STROKE_STYLE"] = "strokeStyle";
|
|
2720
|
+
TokenTypes2["BOX_SHADOW"] = "boxShadow";
|
|
2721
|
+
TokenTypes2["FONT_FAMILIES"] = "fontFamilies";
|
|
2722
|
+
TokenTypes2["FONT_WEIGHTS"] = "fontWeights";
|
|
2723
|
+
TokenTypes2["LINE_HEIGHTS"] = "lineHeights";
|
|
2724
|
+
TokenTypes2["FONT_SIZES"] = "fontSizes";
|
|
2725
|
+
TokenTypes2["LETTER_SPACING"] = "letterSpacing";
|
|
2726
|
+
TokenTypes2["PARAGRAPH_SPACING"] = "paragraphSpacing";
|
|
2727
|
+
TokenTypes2["PARAGRAPH_INDENT"] = "paragraphIndent";
|
|
2728
|
+
TokenTypes2["TEXT_DECORATION"] = "textDecoration";
|
|
2729
|
+
TokenTypes2["TEXT_CASE"] = "textCase";
|
|
2730
|
+
TokenTypes2["COMPOSITION"] = "composition";
|
|
2731
|
+
TokenTypes2["DIMENSION"] = "dimension";
|
|
2732
|
+
TokenTypes2["BORDER"] = "border";
|
|
2733
|
+
TokenTypes2["ASSET"] = "asset";
|
|
2734
|
+
TokenTypes2["BOOLEAN"] = "boolean";
|
|
2735
|
+
TokenTypes2["NUMBER"] = "number";
|
|
2736
|
+
})(TokenTypes || (TokenTypes = {}));
|
|
2737
|
+
|
|
2738
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/BorderValues.js
|
|
2739
|
+
var BorderValues;
|
|
2740
|
+
(function(BorderValues2) {
|
|
2741
|
+
BorderValues2["BORDER_COLOR"] = "color";
|
|
2742
|
+
BorderValues2["BORDER_WIDTH"] = "width";
|
|
2743
|
+
BorderValues2["BORDER_STYLE"] = "style";
|
|
2744
|
+
})(BorderValues || (BorderValues = {}));
|
|
2745
|
+
|
|
2746
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js
|
|
2747
|
+
var StrokeStyleValues;
|
|
2748
|
+
(function(StrokeStyleValues2) {
|
|
2749
|
+
StrokeStyleValues2["SOLID"] = "solid";
|
|
2750
|
+
StrokeStyleValues2["DASHED"] = "dashed";
|
|
2751
|
+
StrokeStyleValues2["DOTTED"] = "dotted";
|
|
2752
|
+
StrokeStyleValues2["DOUBLE"] = "double";
|
|
2753
|
+
StrokeStyleValues2["GROOVE"] = "groove";
|
|
2754
|
+
StrokeStyleValues2["RIDGE"] = "ridge";
|
|
2755
|
+
StrokeStyleValues2["OUTSET"] = "outset";
|
|
2756
|
+
StrokeStyleValues2["INSET"] = "inset";
|
|
2757
|
+
})(StrokeStyleValues || (StrokeStyleValues = {}));
|
|
2758
|
+
|
|
2759
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js
|
|
2760
|
+
var BoxShadowValues;
|
|
2761
|
+
(function(BoxShadowValues2) {
|
|
2762
|
+
BoxShadowValues2["TYPE"] = "type";
|
|
2763
|
+
BoxShadowValues2["COLOR"] = "color";
|
|
2764
|
+
BoxShadowValues2["X"] = "x";
|
|
2765
|
+
BoxShadowValues2["Y"] = "y";
|
|
2766
|
+
BoxShadowValues2["BLUR"] = "blur";
|
|
2767
|
+
BoxShadowValues2["SPREAD"] = "spread";
|
|
2768
|
+
BoxShadowValues2["BLEND_MODE"] = "blendMode";
|
|
2769
|
+
})(BoxShadowValues || (BoxShadowValues = {}));
|
|
2770
|
+
|
|
2771
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/TypographyValues.js
|
|
2772
|
+
var TypographyValues;
|
|
2773
|
+
(function(TypographyValues2) {
|
|
2774
|
+
TypographyValues2["FONT_FAMILY"] = "fontFamily";
|
|
2775
|
+
TypographyValues2["FONT_WEIGHT"] = "fontWeight";
|
|
2776
|
+
TypographyValues2["LINE_HEIGHT"] = "lineHeight";
|
|
2777
|
+
TypographyValues2["FONT_SIZE"] = "fontSize";
|
|
2778
|
+
TypographyValues2["LETTER_SPACING"] = "letterSpacing";
|
|
2779
|
+
TypographyValues2["PARAGRAPH_SPACING"] = "paragraphSpacing";
|
|
2780
|
+
TypographyValues2["PARAGRAPH_INDENT"] = "paragraphIndent";
|
|
2781
|
+
TypographyValues2["TEXT_DECORATION"] = "textDecoration";
|
|
2782
|
+
TypographyValues2["TEXT_CASE"] = "textCase";
|
|
2783
|
+
})(TypographyValues || (TypographyValues = {}));
|
|
2784
|
+
|
|
2785
|
+
// src/tokens/utils/permutateThemes.ts
|
|
2786
|
+
function mapThemesToSetsObject(themes) {
|
|
2787
|
+
return themes.map((theme) => ({ name: theme.name, selectedTokenSets: filterTokenSets(theme.selectedTokenSets) }));
|
|
2788
|
+
}
|
|
2789
|
+
function permutateThemes(themes, { separator: separator2 = "-" } = {}) {
|
|
2790
|
+
if (!themes.some((theme) => theme.group)) {
|
|
2791
|
+
return mapThemesToSetsObject(themes);
|
|
2792
|
+
}
|
|
2793
|
+
const groups = {};
|
|
2794
|
+
themes.forEach((theme) => {
|
|
2795
|
+
if (theme.group) {
|
|
2796
|
+
groups[theme.group] = [...groups[theme.group] ?? [], theme];
|
|
2797
|
+
} else {
|
|
2798
|
+
throw new Error(
|
|
2799
|
+
`Theme ${theme.name} does not have a group property, which is required for multi-dimensional theming.`
|
|
2800
|
+
);
|
|
2801
|
+
}
|
|
2802
|
+
});
|
|
2803
|
+
if (Object.keys(groups).length <= 1) {
|
|
2804
|
+
return mapThemesToSetsObject(themes);
|
|
2805
|
+
}
|
|
2806
|
+
const permutations = cartesian(Object.values(groups));
|
|
2807
|
+
const permutatedThemes = permutations.map((perm) => {
|
|
2808
|
+
const permutatedTheme = perm.reduce(
|
|
2809
|
+
(acc, theme) => {
|
|
2810
|
+
const { group, name, selectedTokenSets } = theme;
|
|
2811
|
+
let updatedPermutatedTheme = acc;
|
|
2812
|
+
if (group) {
|
|
2813
|
+
const groupProp = R2.lensProp(group.toLowerCase());
|
|
2814
|
+
updatedPermutatedTheme = R2.set(groupProp, name.toLowerCase(), updatedPermutatedTheme);
|
|
2815
|
+
}
|
|
2816
|
+
const updatedName = `${String(acc.name)}${acc ? separator2 : ""}${name}`;
|
|
2817
|
+
const sets = [...updatedPermutatedTheme.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
|
|
2818
|
+
return {
|
|
2819
|
+
...updatedPermutatedTheme,
|
|
2820
|
+
name: updatedName,
|
|
2821
|
+
selectedTokenSets: sets
|
|
2822
|
+
};
|
|
2823
|
+
},
|
|
2824
|
+
{ name: "", selectedTokenSets: [] }
|
|
2825
|
+
);
|
|
2826
|
+
const uniqueTokenSets = new Set(permutatedTheme.selectedTokenSets);
|
|
2827
|
+
return { ...permutatedTheme, selectedTokenSets: Array.from(uniqueTokenSets) };
|
|
2828
|
+
});
|
|
2829
|
+
return permutatedThemes;
|
|
2830
|
+
}
|
|
2831
|
+
function filterTokenSets(tokensets) {
|
|
2832
|
+
return Object.entries(tokensets).filter(([, val]) => val !== TokenSetStatus.DISABLED).sort((a, b) => {
|
|
2833
|
+
if (a[1] === TokenSetStatus.SOURCE && b[1] === TokenSetStatus.ENABLED) {
|
|
2834
|
+
return -1;
|
|
2835
|
+
} else if (a[1] === TokenSetStatus.ENABLED && b[1] === TokenSetStatus.SOURCE) {
|
|
2836
|
+
return 1;
|
|
2837
|
+
}
|
|
2838
|
+
return 0;
|
|
2839
|
+
}).map((entry) => entry[0]);
|
|
2840
|
+
}
|
|
2841
|
+
function cartesian(a) {
|
|
2842
|
+
return a.reduce((a2, b) => a2.flatMap((d) => b.map((e) => [d, e].flat())));
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2845
|
+
// src/tokens/transformers.ts
|
|
2846
|
+
import * as R4 from "ramda";
|
|
2847
|
+
|
|
2848
|
+
// src/tokens/utils/noCase.ts
|
|
2849
|
+
var lowerCase = (text = "") => text.toLowerCase();
|
|
2850
|
+
var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
|
|
2851
|
+
var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
|
|
2852
|
+
function noCase(input, options = {}) {
|
|
2853
|
+
const {
|
|
2854
|
+
splitRegexp = DEFAULT_SPLIT_REGEXP,
|
|
2855
|
+
stripRegexp = DEFAULT_STRIP_REGEXP,
|
|
2856
|
+
transform = lowerCase,
|
|
2857
|
+
delimiter = " "
|
|
2858
|
+
} = options;
|
|
2859
|
+
const result = replace(
|
|
2860
|
+
replace(input, splitRegexp, "$1\0$2"),
|
|
2861
|
+
stripRegexp,
|
|
2862
|
+
"\0"
|
|
2863
|
+
);
|
|
2864
|
+
let start = 0;
|
|
2865
|
+
let end = result.length;
|
|
2866
|
+
while (result.charAt(start) === "\0") start++;
|
|
2867
|
+
while (result.charAt(end - 1) === "\0") end--;
|
|
2868
|
+
return result.slice(start, end).split("\0").map(transform).join(delimiter);
|
|
2869
|
+
}
|
|
2870
|
+
function replace(input, re, value) {
|
|
2871
|
+
if (re instanceof RegExp) return input.replace(re, value);
|
|
2872
|
+
return re.reduce((input2, re2) => input2.replace(re2, value), input);
|
|
2873
|
+
}
|
|
2874
|
+
|
|
2875
|
+
// src/tokens/utils/utils.ts
|
|
2876
|
+
import * as R3 from "ramda";
|
|
2877
|
+
var getType = (token) => (token.$type ?? token.type) || "";
|
|
2878
|
+
var getValue = (token) => token.$value ?? token.value;
|
|
2879
|
+
var typeEquals = R3.curry((types, token) => {
|
|
2880
|
+
if (R3.isNil(token)) {
|
|
2881
|
+
return false;
|
|
2882
|
+
}
|
|
2883
|
+
return R3.includes(R3.toLower(getType(token)), R3.map(R3.toLower, Array.isArray(types) ? types : [types]));
|
|
2884
|
+
});
|
|
2885
|
+
|
|
2886
|
+
// src/tokens/transformers.ts
|
|
2887
|
+
var isPx = R4.test(/\b\d+px\b/g);
|
|
2888
|
+
var sizeRem = {
|
|
2889
|
+
name: "ds/size/toRem",
|
|
2890
|
+
type: "value",
|
|
2891
|
+
transitive: true,
|
|
2892
|
+
filter: (token) => typeEquals(["sizing", "spacing", "borderRadius", "fontsizes"], token),
|
|
2893
|
+
transform: (token, config) => {
|
|
2894
|
+
const value = getValue(token);
|
|
2895
|
+
if (isPx(value)) {
|
|
2896
|
+
const baseFont = config.basePxFontSize || 16;
|
|
2897
|
+
const size = parseInt(value);
|
|
2898
|
+
if (size === 0) {
|
|
2899
|
+
return "0";
|
|
2900
|
+
}
|
|
2901
|
+
return `${size / baseFont}rem`;
|
|
2902
|
+
}
|
|
2903
|
+
return value;
|
|
2904
|
+
}
|
|
2905
|
+
};
|
|
2906
|
+
var nameKebab = {
|
|
2907
|
+
name: "name/cti/hierarchical-kebab",
|
|
2908
|
+
type: "name",
|
|
2909
|
+
transform: (token, options) => {
|
|
2910
|
+
return noCase([options?.prefix].concat(token.path).join("-"), {
|
|
2911
|
+
delimiter: "-",
|
|
2912
|
+
stripRegexp: /[^A-Z0-9_]+/gi
|
|
2913
|
+
});
|
|
2914
|
+
}
|
|
2915
|
+
};
|
|
2916
|
+
var typographyShorthand = {
|
|
2917
|
+
name: "typography/shorthand",
|
|
2918
|
+
type: "value",
|
|
2919
|
+
transitive: true,
|
|
2920
|
+
filter: (token) => token.type === "typography",
|
|
2921
|
+
transform: (token) => {
|
|
2922
|
+
const typography2 = getValue(token);
|
|
2923
|
+
return `${typography2.fontWeight} ${typography2.fontSize}/${typography2.lineHeight} '${typography2.fontFamily}'`;
|
|
2924
|
+
}
|
|
2925
|
+
};
|
|
2926
|
+
|
|
2927
|
+
// src/tokens/formats/js-tokens.ts
|
|
2928
|
+
import * as R5 from "ramda";
|
|
2929
|
+
import { fileHeader, createPropertyFormatter } from "style-dictionary/utils";
|
|
2930
|
+
var groupByType = R5.groupBy((token) => getType(token));
|
|
2931
|
+
var removeUnwatedTokens = R5.filter(
|
|
2932
|
+
(token) => !["fds-base_spacing", "fds-base_sizing"].includes(token.name)
|
|
2933
|
+
);
|
|
2934
|
+
var toCssVarName = R5.pipe(R5.split(":"), R5.head, R5.trim);
|
|
2935
|
+
var jsTokens = {
|
|
2936
|
+
name: "ds/js-tokens",
|
|
2937
|
+
format: async function({ dictionary, file }) {
|
|
2938
|
+
const format = createPropertyFormatter({
|
|
2939
|
+
dictionary,
|
|
2940
|
+
format: "css"
|
|
2941
|
+
});
|
|
2942
|
+
const formatTokens = R5.map((token) => ({
|
|
2943
|
+
...token,
|
|
2944
|
+
name: toCssVarName(format(token))
|
|
2945
|
+
}));
|
|
2946
|
+
const processTokens = R5.pipe(removeUnwatedTokens, formatTokens, groupByType);
|
|
2947
|
+
const tokens = processTokens(dictionary.allTokens);
|
|
2948
|
+
const content = Object.entries(tokens).map(
|
|
2949
|
+
([name, token]) => `export const ${name} = ${JSON.stringify(token, null, 2).replace(/"([^"]+)":/g, "$1:")}
|
|
2950
|
+
`
|
|
2951
|
+
).join("\n");
|
|
2952
|
+
return fileHeader({ file }).then((fileHeaderText) => fileHeaderText + content);
|
|
2953
|
+
}
|
|
2954
|
+
};
|
|
2955
|
+
|
|
2956
|
+
// src/tokens/formats/css.ts
|
|
2957
|
+
import * as R6 from "ramda";
|
|
2958
|
+
import { fileHeader as fileHeader2, createPropertyFormatter as createPropertyFormatter2, usesReferences, getReferences } from "style-dictionary/utils";
|
|
2959
|
+
var prefersColorScheme = (mode, content) => `
|
|
2960
|
+
@media (prefers-color-scheme: ${mode}) {
|
|
2961
|
+
[data-ds-color-mode="auto"] ${content}
|
|
2962
|
+
}
|
|
2963
|
+
`;
|
|
2964
|
+
var colormode = {
|
|
2965
|
+
name: "ds/css-colormode",
|
|
2966
|
+
format: async function({ dictionary, file, options, platform }) {
|
|
2967
|
+
const { allTokens } = dictionary;
|
|
2968
|
+
const { outputReferences } = options;
|
|
2969
|
+
const { selector, mode, layer } = platform;
|
|
2970
|
+
const mode_ = mode;
|
|
2971
|
+
const header = await fileHeader2({ file });
|
|
2972
|
+
const format = createPropertyFormatter2({
|
|
2973
|
+
outputReferences,
|
|
2974
|
+
dictionary,
|
|
2975
|
+
format: "css"
|
|
2976
|
+
});
|
|
2977
|
+
const content = `{
|
|
2978
|
+
${allTokens.map(format).join("\n")}
|
|
2979
|
+
}
|
|
2980
|
+
`;
|
|
2981
|
+
const autoSelectorContent = ["light", "dark"].includes(mode_) ? prefersColorScheme(mode_, content) : "";
|
|
2982
|
+
return header + `@layer ${layer} {
|
|
2983
|
+
${selector} ${content} ${autoSelectorContent}
|
|
2984
|
+
}
|
|
2985
|
+
`;
|
|
2986
|
+
}
|
|
2987
|
+
};
|
|
2988
|
+
var calculatedVariable = R6.pipe(R6.split(/:(.*?);/g), (split3) => `${split3[0]}: calc(${R6.trim(split3[1])});`);
|
|
2989
|
+
var semantic = {
|
|
2990
|
+
name: "ds/css-semantic",
|
|
2991
|
+
format: async function({ dictionary, file, options, platform }) {
|
|
2992
|
+
const { allTokens } = dictionary;
|
|
2993
|
+
const { outputReferences } = options;
|
|
2994
|
+
const { selector, isCalculatedToken, layer } = platform;
|
|
2995
|
+
const header = await fileHeader2({ file });
|
|
2996
|
+
const format = createPropertyFormatter2({
|
|
2997
|
+
outputReferences,
|
|
2998
|
+
dictionary,
|
|
2999
|
+
format: "css"
|
|
3000
|
+
});
|
|
3001
|
+
const formatTokens = R6.map((token) => {
|
|
3002
|
+
const originalValue = getValue(token.original);
|
|
3003
|
+
if (usesReferences(originalValue) && typeof outputReferences === "function" && outputReferences?.(token, { dictionary })) {
|
|
3004
|
+
if (isCalculatedToken?.(token, options)) {
|
|
3005
|
+
return calculatedVariable(format(token));
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
3008
|
+
return format(token);
|
|
3009
|
+
});
|
|
3010
|
+
const formattedVariables = formatTokens(allTokens);
|
|
3011
|
+
const content = `{
|
|
3012
|
+
${formattedVariables.join("\n")}
|
|
3013
|
+
}
|
|
3014
|
+
`;
|
|
3015
|
+
return header + `@layer ${layer} {
|
|
3016
|
+
${selector} ${content}
|
|
3017
|
+
}
|
|
3018
|
+
`;
|
|
3019
|
+
}
|
|
3020
|
+
};
|
|
3021
|
+
var sortByType = R6.sortBy((token) => token?.type === "typography");
|
|
3022
|
+
var getVariableName = R6.pipe(
|
|
3023
|
+
R6.split(":"),
|
|
3024
|
+
R6.head,
|
|
3025
|
+
R6.defaultTo(""),
|
|
3026
|
+
R6.trim,
|
|
3027
|
+
(name) => `var(${name})`
|
|
3028
|
+
);
|
|
3029
|
+
var bemify = R6.pipe(
|
|
3030
|
+
(path2) => {
|
|
3031
|
+
const filteredPath = path2.filter((p) => p !== "typography");
|
|
3032
|
+
const withPrefix = R6.concat([prefix], R6.remove(0, 0, filteredPath));
|
|
3033
|
+
const [rest, last] = R6.splitAt(-1, withPrefix);
|
|
3034
|
+
const className = `${rest.join("-")}--${R6.head(last)}`;
|
|
3035
|
+
return className;
|
|
3036
|
+
},
|
|
3037
|
+
R6.trim,
|
|
3038
|
+
R6.toLower
|
|
3039
|
+
);
|
|
3040
|
+
var classSelector = R6.pipe(R6.prop("path"), bemify);
|
|
3041
|
+
var sortTypographyLast = R6.sortWith([
|
|
3042
|
+
R6.ascend((token) => typeEquals("typography")(token) ? 1 : 0)
|
|
3043
|
+
]);
|
|
3044
|
+
var typography = {
|
|
3045
|
+
name: "ds/css-typography",
|
|
3046
|
+
format: async function({ dictionary, file, options, platform }) {
|
|
3047
|
+
const { outputReferences } = options;
|
|
3048
|
+
const { selector, layer } = platform;
|
|
3049
|
+
const header = await fileHeader2({ file });
|
|
3050
|
+
const format = createPropertyFormatter2({
|
|
3051
|
+
outputReferences,
|
|
3052
|
+
dictionary,
|
|
3053
|
+
format: "css"
|
|
3054
|
+
});
|
|
3055
|
+
const sortedTokens = sortTypographyLast(dictionary.allTokens);
|
|
3056
|
+
const formattedTokens = R6.pipe(
|
|
3057
|
+
sortByType,
|
|
3058
|
+
R6.reduce(
|
|
3059
|
+
(acc, token) => {
|
|
3060
|
+
if (typeEquals("fontweights", token)) {
|
|
3061
|
+
const className = `
|
|
3062
|
+
.${classSelector(token)} {
|
|
3063
|
+
font-weight: ${getValue(token)};
|
|
3064
|
+
}`;
|
|
3065
|
+
return {
|
|
3066
|
+
...acc,
|
|
3067
|
+
variables: [...acc.variables, format(token)],
|
|
3068
|
+
classes: [...acc.classes, className]
|
|
3069
|
+
};
|
|
3070
|
+
}
|
|
3071
|
+
if (typeEquals("lineheights", token)) {
|
|
3072
|
+
const className = `
|
|
3073
|
+
.${classSelector(token)} {
|
|
3074
|
+
line-height: ${getValue(token)};
|
|
3075
|
+
}`;
|
|
3076
|
+
return {
|
|
3077
|
+
...acc,
|
|
3078
|
+
variables: [...acc.variables, format(token)],
|
|
3079
|
+
classes: [...acc.classes, className]
|
|
3080
|
+
};
|
|
3081
|
+
}
|
|
3082
|
+
if (typeEquals("typography", token)) {
|
|
3083
|
+
const references = getReferences(getValue(token.original), dictionary.tokens);
|
|
3084
|
+
const fontweight = R6.find(typeEquals(["fontweights"]))(references);
|
|
3085
|
+
const lineheight = R6.find(typeEquals(["lineheights"]))(references);
|
|
3086
|
+
const fontsize = R6.find(typeEquals(["fontsizes"]))(references);
|
|
3087
|
+
const letterSpacing = R6.find(typeEquals(["letterSpacing"]))(references);
|
|
3088
|
+
const fontSizeVar = fontsize ? getVariableName(format(fontsize)) : null;
|
|
3089
|
+
const fontWeightVar = fontweight ? getVariableName(format(fontweight)) : null;
|
|
3090
|
+
const lineheightVar = lineheight ? getVariableName(format(lineheight)) : null;
|
|
3091
|
+
const letterSpacingVar = letterSpacing ? getVariableName(format(letterSpacing)) : null;
|
|
3092
|
+
const className = `
|
|
3093
|
+
.${classSelector(token)} {
|
|
3094
|
+
${fontSizeVar && `font-size: ${fontSizeVar};`}
|
|
3095
|
+
${lineheightVar && `line-height: ${lineheightVar};`}
|
|
3096
|
+
${fontWeightVar && `font-weight: ${fontWeightVar};`}
|
|
3097
|
+
${letterSpacingVar && `letter-spacing: ${letterSpacingVar};`}
|
|
3098
|
+
}`;
|
|
3099
|
+
return { ...acc, classes: [className, ...acc.classes] };
|
|
3100
|
+
}
|
|
3101
|
+
return { ...acc, variables: [...acc.variables, format(token)] };
|
|
3102
|
+
},
|
|
3103
|
+
{ variables: [], classes: [] }
|
|
3104
|
+
)
|
|
3105
|
+
)(sortedTokens);
|
|
3106
|
+
const classes = formattedTokens.classes.join("\n");
|
|
3107
|
+
const variables = formattedTokens.variables.join("\n");
|
|
3108
|
+
const content = selector ? `${selector} {
|
|
3109
|
+
${variables}
|
|
3110
|
+
${classes}
|
|
3111
|
+
}` : classes;
|
|
3112
|
+
return header + `@layer ${layer} {
|
|
3113
|
+
${content}
|
|
3114
|
+
}
|
|
3115
|
+
`;
|
|
3116
|
+
}
|
|
3117
|
+
};
|
|
3118
|
+
|
|
3119
|
+
// src/tokens/actions.ts
|
|
3120
|
+
var import_fs_extra = __toESM(require_lib(), 1);
|
|
3121
|
+
import glob3 from "fast-glob";
|
|
3122
|
+
import chalk3 from "chalk";
|
|
3123
|
+
import * as R7 from "ramda";
|
|
3124
|
+
var sortLightmodeFirst = R7.sortWith([R7.descend(R7.includes("light")), R7.descend(R7.includes("secondary"))]);
|
|
3125
|
+
var makeEntryFile = {
|
|
3126
|
+
name: "make_entryfile",
|
|
3127
|
+
do: async function(dictionary, platform) {
|
|
3128
|
+
const { outPath, theme, log } = platform;
|
|
3129
|
+
const writePath = `${outPath}/${theme}.css`;
|
|
3130
|
+
if (log?.verbosity !== "silent") {
|
|
3131
|
+
console.log(chalk3.green(`Creating entry file: ${writePath}`));
|
|
3132
|
+
}
|
|
3133
|
+
const generateImportUrls = R7.pipe(
|
|
3134
|
+
sortLightmodeFirst,
|
|
3135
|
+
R7.map((file) => `@import url('./${theme}/${file.toString()}');`),
|
|
3136
|
+
R7.join("\n")
|
|
3137
|
+
);
|
|
3138
|
+
const files = await glob3(`**/*`, { cwd: platform.buildPath });
|
|
3139
|
+
const content = generateImportUrls(files);
|
|
3140
|
+
await import_fs_extra.default.writeFile(writePath, content);
|
|
3141
|
+
},
|
|
3142
|
+
undo: async function noOp() {
|
|
3143
|
+
}
|
|
3144
|
+
};
|
|
3145
|
+
|
|
3146
|
+
// src/tokens/configs.ts
|
|
3147
|
+
void tokenStudio.registerTransforms(StyleDictionary);
|
|
3148
|
+
var prefix = "ds";
|
|
3149
|
+
var basePxFontSize = 16;
|
|
3150
|
+
var separator = "_";
|
|
3151
|
+
var fileHeader3 = () => [`These files are generated from design tokens defind using Token Studio`];
|
|
3152
|
+
StyleDictionary.registerTransform(sizeRem);
|
|
3153
|
+
StyleDictionary.registerTransform(nameKebab);
|
|
3154
|
+
StyleDictionary.registerTransform(typographyShorthand);
|
|
3155
|
+
StyleDictionary.registerFormat(jsTokens);
|
|
3156
|
+
StyleDictionary.registerFormat(colormode);
|
|
3157
|
+
StyleDictionary.registerFormat(semantic);
|
|
3158
|
+
StyleDictionary.registerFormat(typography);
|
|
3159
|
+
StyleDictionary.registerAction(makeEntryFile);
|
|
3160
|
+
var dsTransformers = [
|
|
3161
|
+
nameKebab.name,
|
|
3162
|
+
`ts/resolveMath`,
|
|
3163
|
+
"ts/size/px",
|
|
3164
|
+
sizeRem.name,
|
|
3165
|
+
"ts/typography/fontWeight",
|
|
3166
|
+
typographyShorthand.name,
|
|
3167
|
+
"ts/color/modifiers",
|
|
3168
|
+
"ts/color/css/hexrgba",
|
|
3169
|
+
"ts/size/lineheight",
|
|
3170
|
+
"ts/shadow/css/shorthand"
|
|
3171
|
+
];
|
|
3172
|
+
var paritionPrimitives = R8.partition(R8.test(/(?!.*global\.json).*primitives.*/));
|
|
3173
|
+
var hasUnknownProps = R8.pipe(R8.values, R8.none(R8.equals("unknown")), R8.not);
|
|
3174
|
+
var outputColorReferences = (token) => {
|
|
3175
|
+
if (R8.test(/accent|neutral|brand1|brand2|brand3|success|danger|warning/, token.name) && R8.includes("semantic/color", token.filePath)) {
|
|
3176
|
+
return true;
|
|
3177
|
+
}
|
|
3178
|
+
return false;
|
|
3179
|
+
};
|
|
3180
|
+
var permutateThemes2 = ($themes) => permutateThemes($themes, {
|
|
3181
|
+
separator
|
|
3182
|
+
});
|
|
3183
|
+
var colorModeVariables = ({ mode = "light", outPath, theme }) => {
|
|
3184
|
+
const selector = `${mode === "light" ? ":root, " : ""}[data-ds-color-mode="${mode}"]`;
|
|
3185
|
+
const layer = `ds.theme.color.${mode}`;
|
|
3186
|
+
return {
|
|
3187
|
+
log: { verbosity: "silent" },
|
|
3188
|
+
preprocessors: ["tokens-studio"],
|
|
3189
|
+
platforms: {
|
|
3190
|
+
css: {
|
|
3191
|
+
// custom
|
|
3192
|
+
outPath,
|
|
3193
|
+
mode,
|
|
3194
|
+
theme,
|
|
3195
|
+
selector,
|
|
3196
|
+
layer,
|
|
3197
|
+
//
|
|
3198
|
+
prefix,
|
|
3199
|
+
buildPath: `${outPath}/${theme}/`,
|
|
3200
|
+
transforms: dsTransformers,
|
|
3201
|
+
actions: [makeEntryFile.name],
|
|
3202
|
+
files: [
|
|
3203
|
+
{
|
|
3204
|
+
destination: `color-mode/${mode}.css`,
|
|
3205
|
+
format: colormode.name,
|
|
3206
|
+
filter: (token) => !token.isSource && typeEquals("color", token)
|
|
3207
|
+
}
|
|
3208
|
+
],
|
|
3209
|
+
options: {
|
|
3210
|
+
fileHeader: fileHeader3,
|
|
3211
|
+
outputReferences: (token, options) => outputColorReferences(token) && outputReferencesFilter(token, options)
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
};
|
|
3216
|
+
};
|
|
3217
|
+
var semanticVariables = ({ outPath, theme }) => {
|
|
3218
|
+
const selector = `:root`;
|
|
3219
|
+
const layer = `ds.theme.semantic`;
|
|
3220
|
+
const isCalculatedToken = (token) => typeEquals(["spacing", "sizing", "borderRadius"], token);
|
|
3221
|
+
return {
|
|
3222
|
+
log: { verbosity: "silent" },
|
|
3223
|
+
preprocessors: ["tokens-studio"],
|
|
3224
|
+
platforms: {
|
|
3225
|
+
css: {
|
|
3226
|
+
// custom
|
|
3227
|
+
outPath,
|
|
3228
|
+
theme,
|
|
3229
|
+
basePxFontSize,
|
|
3230
|
+
isCalculatedToken,
|
|
3231
|
+
selector,
|
|
3232
|
+
layer,
|
|
3233
|
+
//
|
|
3234
|
+
prefix,
|
|
3235
|
+
buildPath: `${outPath}/${theme}/`,
|
|
3236
|
+
transforms: dsTransformers,
|
|
3237
|
+
actions: [makeEntryFile.name],
|
|
3238
|
+
files: [
|
|
3239
|
+
{
|
|
3240
|
+
destination: `semantic.css`,
|
|
3241
|
+
format: semantic.name,
|
|
3242
|
+
filter: (token) => (!token.isSource || isCalculatedToken(token)) && !typeEquals(["color", "fontWeights", "fontFamilies"], token)
|
|
3243
|
+
}
|
|
3244
|
+
],
|
|
3245
|
+
options: {
|
|
3246
|
+
fileHeader: fileHeader3,
|
|
3247
|
+
outputReferences: (token, options) => isCalculatedToken(token) && outputReferencesFilter(token, options)
|
|
3248
|
+
}
|
|
3249
|
+
}
|
|
3250
|
+
}
|
|
3251
|
+
};
|
|
3252
|
+
};
|
|
3253
|
+
var typescriptTokens = ({ mode = "unknown", outPath, theme }) => {
|
|
3254
|
+
return {
|
|
3255
|
+
log: { verbosity: "silent" },
|
|
3256
|
+
preprocessors: ["tokens-studio"],
|
|
3257
|
+
platforms: {
|
|
3258
|
+
ts: {
|
|
3259
|
+
prefix,
|
|
3260
|
+
basePxFontSize,
|
|
3261
|
+
transforms: dsTransformers,
|
|
3262
|
+
buildPath: `${outPath}/${theme}/`,
|
|
3263
|
+
files: [
|
|
3264
|
+
{
|
|
3265
|
+
destination: `${mode}.ts`,
|
|
3266
|
+
format: jsTokens.name,
|
|
3267
|
+
outputReferences: outputColorReferences,
|
|
3268
|
+
filter: (token) => {
|
|
3269
|
+
if (R8.test(/primitives\/modes|\/themes/, token.filePath)) {
|
|
3270
|
+
return false;
|
|
3271
|
+
}
|
|
3272
|
+
if (R8.test(/accent|neutral|brand1|brand2|brand3|success|danger|warning/, token.name) || R8.includes("semantic", token.filePath)) {
|
|
3273
|
+
return true;
|
|
3274
|
+
}
|
|
3275
|
+
return false;
|
|
3276
|
+
}
|
|
3277
|
+
}
|
|
3278
|
+
],
|
|
3279
|
+
options: {
|
|
3280
|
+
fileHeader: fileHeader3
|
|
3281
|
+
}
|
|
3282
|
+
}
|
|
3283
|
+
}
|
|
3284
|
+
};
|
|
3285
|
+
};
|
|
3286
|
+
var typographyCSS = ({ outPath, theme, typography: typography2 }) => {
|
|
3287
|
+
const selector = `${typography2 === "primary" ? ":root, " : ""}[data-ds-typography="${typography2}"]`;
|
|
3288
|
+
const layer = `ds.theme.typography.${typography2}`;
|
|
3289
|
+
return {
|
|
3290
|
+
log: { verbosity: "silent" },
|
|
3291
|
+
preprocessors: ["tokens-studio"],
|
|
3292
|
+
platforms: {
|
|
3293
|
+
css: {
|
|
3294
|
+
prefix,
|
|
3295
|
+
typography: typography2,
|
|
3296
|
+
selector,
|
|
3297
|
+
layer,
|
|
3298
|
+
buildPath: `${outPath}/${theme}/`,
|
|
3299
|
+
basePxFontSize,
|
|
3300
|
+
transforms: [nameKebab.name, "ts/size/px", sizeRem.name, "ts/size/lineheight", "ts/typography/fontWeight"],
|
|
3301
|
+
files: [
|
|
3302
|
+
{
|
|
3303
|
+
destination: `typography/${typography2}.css`,
|
|
3304
|
+
format: typography.name,
|
|
3305
|
+
filter: (token) => {
|
|
3306
|
+
return typeEquals(
|
|
3307
|
+
["typography", "fontweights", "fontfamilies", "lineheights", "fontsizes", "letterSpacing"],
|
|
3308
|
+
token
|
|
3309
|
+
) && !(token.path[0] || "").startsWith("theme");
|
|
3310
|
+
}
|
|
3311
|
+
}
|
|
3312
|
+
],
|
|
3313
|
+
options: {
|
|
3314
|
+
fileHeader: fileHeader3
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
3318
|
+
};
|
|
3319
|
+
};
|
|
3320
|
+
var getConfigs = (getConfig, outPath, tokensDir, permutatedThemes) => permutatedThemes.map((permutatedTheme) => {
|
|
3321
|
+
const {
|
|
3322
|
+
selectedTokenSets = [],
|
|
3323
|
+
mode = "unknown",
|
|
3324
|
+
theme = "unknown",
|
|
3325
|
+
semantic: semantic2 = "unknown",
|
|
3326
|
+
size = "unknown",
|
|
3327
|
+
typography: typography2 = "unknown"
|
|
3328
|
+
} = permutatedTheme;
|
|
3329
|
+
if (hasUnknownProps(permutatedTheme)) {
|
|
3330
|
+
throw Error(`Theme ${permutatedTheme.name} has unknown props: ${JSON.stringify(permutatedTheme)}`);
|
|
3331
|
+
}
|
|
3332
|
+
const setsWithPaths = selectedTokenSets.map((x) => `${tokensDir}/${x}.json`);
|
|
3333
|
+
const [source, include] = paritionPrimitives(setsWithPaths);
|
|
3334
|
+
const config_ = getConfig({
|
|
3335
|
+
outPath,
|
|
3336
|
+
theme,
|
|
3337
|
+
mode,
|
|
3338
|
+
semantic: semantic2,
|
|
3339
|
+
size,
|
|
3340
|
+
typography: typography2
|
|
3341
|
+
});
|
|
3342
|
+
const config = {
|
|
3343
|
+
...config_,
|
|
3344
|
+
source,
|
|
3345
|
+
include
|
|
3346
|
+
};
|
|
3347
|
+
return { mode, theme, semantic: semantic2, size, typography: typography2, config };
|
|
3348
|
+
}).sort();
|
|
3349
|
+
|
|
3350
|
+
// src/tokens/build.ts
|
|
3351
|
+
var { permutateThemes: permutateThemes3, getConfigs: getConfigs2 } = configs_exports;
|
|
3352
|
+
var sd = new StyleDictionary2();
|
|
3353
|
+
async function run(options) {
|
|
3354
|
+
const tokensDir = options.tokens;
|
|
3355
|
+
const storefrontOutDir = path.resolve("../../apps/storefront/tokens");
|
|
3356
|
+
const tokensOutDir = path.resolve(options.out);
|
|
3357
|
+
const $themes = JSON.parse(fs3.readFileSync(path.resolve(`${tokensDir}/$themes.json`), "utf-8"));
|
|
3358
|
+
const relevant$themes = $themes.filter((theme) => {
|
|
3359
|
+
const group = R9.toLower(R9.defaultTo("")(theme.group));
|
|
3360
|
+
if (group === "size" && theme.name !== "default") return false;
|
|
3361
|
+
return true;
|
|
3362
|
+
});
|
|
3363
|
+
const themes = permutateThemes3(relevant$themes);
|
|
3364
|
+
const typographyThemes = R9.filter((val) => val.mode === "light", themes);
|
|
3365
|
+
const colormodeThemes = R9.filter((val) => val.typography === "primary", themes);
|
|
3366
|
+
const semanticThemes = R9.filter((val) => val.mode === "light" && val.typography === "primary", themes);
|
|
3367
|
+
const colorModeConfigs = getConfigs2(colorModeVariables, tokensOutDir, tokensDir, colormodeThemes);
|
|
3368
|
+
const semanticConfigs = getConfigs2(semanticVariables, tokensOutDir, tokensDir, semanticThemes);
|
|
3369
|
+
const typographyConfigs = getConfigs2(typographyCSS, tokensOutDir, tokensDir, typographyThemes);
|
|
3370
|
+
const storefrontConfigs = getConfigs2(typescriptTokens, storefrontOutDir, tokensDir, colormodeThemes);
|
|
3371
|
+
if (typographyConfigs.length > 0) {
|
|
3372
|
+
console.log(`
|
|
3373
|
+
\u{1F371} Building ${chalk4.green("typography")}`);
|
|
3374
|
+
await Promise.all(
|
|
3375
|
+
typographyConfigs.map(async ({ theme, typography: typography2, config }) => {
|
|
3376
|
+
console.log(`\u{1F477} ${theme} - ${typography2}`);
|
|
3377
|
+
const typographyClasses = await sd.extend(config);
|
|
3378
|
+
return typographyClasses.buildAllPlatforms();
|
|
3379
|
+
})
|
|
3380
|
+
);
|
|
3381
|
+
}
|
|
3382
|
+
if (semanticConfigs.length > 0) {
|
|
3383
|
+
console.log(`
|
|
3384
|
+
\u{1F371} Building ${chalk4.green("semantic")}`);
|
|
3385
|
+
await Promise.all(
|
|
3386
|
+
semanticConfigs.map(async ({ theme, config, semantic: semantic2 }) => {
|
|
3387
|
+
console.log(`\u{1F477} ${theme} - ${semantic2}`);
|
|
3388
|
+
const typographyClasses = await sd.extend(config);
|
|
3389
|
+
return typographyClasses.buildAllPlatforms();
|
|
3390
|
+
})
|
|
3391
|
+
);
|
|
3392
|
+
}
|
|
3393
|
+
if (colorModeConfigs.length > 0) {
|
|
3394
|
+
console.log(`
|
|
3395
|
+
\u{1F371} Building ${chalk4.green("color-mode")}`);
|
|
3396
|
+
await Promise.all(
|
|
3397
|
+
colorModeConfigs.map(async ({ theme, mode, config }) => {
|
|
3398
|
+
console.log(`\u{1F477} ${theme} - ${mode}`);
|
|
3399
|
+
const themeVariablesSD = await sd.extend(config);
|
|
3400
|
+
return themeVariablesSD.buildAllPlatforms();
|
|
3401
|
+
})
|
|
3402
|
+
);
|
|
3403
|
+
}
|
|
3404
|
+
if (storefrontConfigs.length > 0 && options.preview) {
|
|
3405
|
+
console.log(`
|
|
3406
|
+
\u{1F371} Building ${chalk4.green("Storefront preview tokens")}`);
|
|
3407
|
+
await Promise.all(
|
|
3408
|
+
storefrontConfigs.map(async ({ theme, mode, config }) => {
|
|
3409
|
+
console.log(`\u{1F477} ${theme} - ${mode}`);
|
|
3410
|
+
const storefrontSD = await sd.extend(config);
|
|
3411
|
+
return storefrontSD.buildAllPlatforms();
|
|
3412
|
+
})
|
|
3413
|
+
);
|
|
3414
|
+
}
|
|
3415
|
+
}
|
|
3416
|
+
|
|
3417
|
+
// bin/designsystemet.ts
|
|
3418
|
+
program.name("Designsystemet").description("CLI for working with Designsystemet");
|
|
3419
|
+
program.command("tokens").showHelpAfterError().description("run Designsystemet token builder").option("-t, --tokens [string]", `Path to ${chalk5.blue("design-tokens")}`, "./design-tokens").option("-o, --out [string]", `Output directory for built ${chalk5.blue("design-tokens")}`, "./dist/tokens").option("-p, --preview", "Generate preview token.ts files", false).action((opts) => {
|
|
3420
|
+
const tokens = typeof opts.tokens === "string" ? opts.tokens : "./design-tokens";
|
|
3421
|
+
const out = typeof opts.out === "string" ? opts.out : "./dist/tokens";
|
|
3422
|
+
const preview = opts.preview;
|
|
3423
|
+
console.log(`Bulding tokens in ${chalk5.green(tokens)}`);
|
|
3424
|
+
return run({ tokens, out, preview });
|
|
3425
|
+
});
|
|
3426
|
+
program.command("migrate").showHelpAfterError().description("run a Designsystemet migration").addArgument(new Argument("[migration]", "Available migrations").choices(Object.keys(migrations_default))).option("-l --list", "List available migrations").option("-g --glob <glob>", "Glob for files upon which to apply the migration", "./**/*.(tsx|css)").action((migrationKey, opts) => {
|
|
3427
|
+
const { glob: glob4, list } = opts;
|
|
3428
|
+
if (list) {
|
|
3429
|
+
Object.keys(migrations_default).forEach((key) => {
|
|
3430
|
+
console.log(key);
|
|
3431
|
+
});
|
|
3432
|
+
} else if (migrationKey) {
|
|
3433
|
+
const migration = migrations_default[migrationKey];
|
|
3434
|
+
if (!migration) {
|
|
3435
|
+
console.error("Migration not found!");
|
|
3436
|
+
throw "Aborting";
|
|
3437
|
+
}
|
|
3438
|
+
console.log(`Applying migration ${chalk5.blue(migrationKey)} with glob: ${chalk5.green(glob4)}`);
|
|
3439
|
+
migration?.(glob4).then(() => console.log(`Migration ${chalk5.blue(migrationKey)} finished`)).catch((error) => console.log(error));
|
|
3440
|
+
} else {
|
|
3441
|
+
console.log("Migrate: please specify a migration name or --list");
|
|
3442
|
+
}
|
|
3443
|
+
});
|
|
3444
|
+
await program.parseAsync(process.argv);
|
|
3445
|
+
//# sourceMappingURL=designsystemet.js.map
|