@sapphire-sh/utils 1.73.0 → 1.75.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/sapphire-bootstrap.js +24 -6
- package/lib/cjs/interceptXHR.d.ts.map +1 -1
- package/lib/cjs/interceptXHR.js +1 -3
- package/lib/cjs/interceptXHR.js.map +1 -1
- package/lib/interceptXHR.d.ts.map +1 -1
- package/lib/interceptXHR.js +1 -3
- package/lib/interceptXHR.js.map +1 -1
- package/package.json +1 -1
- package/templates/.github/workflows/utils-update.yml +13 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { copyFileSync, existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
4
|
-
import { join } from 'node:path';
|
|
3
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { dirname, join } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
|
|
7
7
|
const START_MARKER = '# @sapphire-sh/utils:start';
|
|
@@ -42,13 +42,31 @@ const writeSectioned = (outputName, content) => {
|
|
|
42
42
|
console.log(`wrote ${outputName}`);
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
const
|
|
45
|
+
const collectTemplates = (directory, prefix) => {
|
|
46
|
+
const relativePaths = [];
|
|
47
|
+
|
|
48
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
49
|
+
const relativePath = prefix === '' ? entry.name : join(prefix, entry.name);
|
|
50
|
+
|
|
51
|
+
if (entry.isDirectory()) {
|
|
52
|
+
relativePaths.push(...collectTemplates(join(directory, entry.name), relativePath));
|
|
53
|
+
} else {
|
|
54
|
+
relativePaths.push(relativePath);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return relativePaths;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
for (const relativePath of collectTemplates(templatesDir, '')) {
|
|
62
|
+
const outputName = renameMap.get(relativePath) ?? relativePath;
|
|
47
63
|
if (sectioned.has(outputName)) {
|
|
48
|
-
const content = readFileSync(join(templatesDir,
|
|
64
|
+
const content = readFileSync(join(templatesDir, relativePath), 'utf-8');
|
|
49
65
|
writeSectioned(outputName, content);
|
|
50
66
|
} else {
|
|
51
|
-
|
|
67
|
+
const outputPath = join(cwd, outputName);
|
|
68
|
+
mkdirSync(dirname(outputPath), { recursive: true });
|
|
69
|
+
copyFileSync(join(templatesDir, relativePath), outputPath);
|
|
52
70
|
console.log(`wrote ${outputName}`);
|
|
53
71
|
}
|
|
54
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interceptXHR.d.ts","sourceRoot":"","sources":["../../src/interceptXHR.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,GAAG,MAAM,EAAE,SAAS,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"interceptXHR.d.ts","sourceRoot":"","sources":["../../src/interceptXHR.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,GAAG,MAAM,EAAE,SAAS,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,SAiB5F,CAAC"}
|
package/lib/cjs/interceptXHR.js
CHANGED
|
@@ -8,9 +8,7 @@ const interceptXHR = (pattern, handler) => {
|
|
|
8
8
|
if (this.status !== 200) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
|
-
const matches = typeof pattern === 'string'
|
|
12
|
-
? this.responseURL.includes(pattern)
|
|
13
|
-
: pattern.test(this.responseURL);
|
|
11
|
+
const matches = typeof pattern === 'string' ? this.responseURL.includes(pattern) : pattern.test(this.responseURL);
|
|
14
12
|
if (!matches) {
|
|
15
13
|
return;
|
|
16
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interceptXHR.js","sourceRoot":"","sources":["../../src/interceptXHR.ts"],"names":[],"mappings":";;;AAAA,MAAM,YAAY,GAAG,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC;AAE5C,MAAM,YAAY,GAAG,CAAC,OAAwB,EAAE,OAAsC,EAAE,EAAE;IAChG,cAAc,CAAC,SAAS,CAAC,IAAI,GAAG,UAAU,IAAI;QAC7C,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE;YAClC,IAAI,IAAI,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBACzB,OAAO;YACR,CAAC;YAED,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"interceptXHR.js","sourceRoot":"","sources":["../../src/interceptXHR.ts"],"names":[],"mappings":";;;AAAA,MAAM,YAAY,GAAG,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC;AAE5C,MAAM,YAAY,GAAG,CAAC,OAAwB,EAAE,OAAsC,EAAE,EAAE;IAChG,cAAc,CAAC,SAAS,CAAC,IAAI,GAAG,UAAU,IAAI;QAC7C,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE;YAClC,IAAI,IAAI,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBACzB,OAAO;YACR,CAAC;YAED,MAAM,OAAO,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAElH,IAAI,CAAC,OAAO,EAAE,CAAC;gBACd,OAAO;YACR,CAAC;YAED,OAAO,CAAC,IAAI,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;QACH,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC,CAAC;AACH,CAAC,CAAC;AAjBW,QAAA,YAAY,gBAiBvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interceptXHR.d.ts","sourceRoot":"","sources":["../src/interceptXHR.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,GAAG,MAAM,EAAE,SAAS,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"interceptXHR.d.ts","sourceRoot":"","sources":["../src/interceptXHR.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,GAAG,MAAM,EAAE,SAAS,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,SAiB5F,CAAC"}
|
package/lib/interceptXHR.js
CHANGED
|
@@ -5,9 +5,7 @@ export const interceptXHR = (pattern, handler) => {
|
|
|
5
5
|
if (this.status !== 200) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
|
-
const matches = typeof pattern === 'string'
|
|
9
|
-
? this.responseURL.includes(pattern)
|
|
10
|
-
: pattern.test(this.responseURL);
|
|
8
|
+
const matches = typeof pattern === 'string' ? this.responseURL.includes(pattern) : pattern.test(this.responseURL);
|
|
11
9
|
if (!matches) {
|
|
12
10
|
return;
|
|
13
11
|
}
|
package/lib/interceptXHR.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interceptXHR.js","sourceRoot":"","sources":["../src/interceptXHR.ts"],"names":[],"mappings":"AAAA,MAAM,YAAY,GAAG,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC;AAEnD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAwB,EAAE,OAAsC,EAAE,EAAE;IAChG,cAAc,CAAC,SAAS,CAAC,IAAI,GAAG,UAAU,IAAI;QAC7C,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE;YAClC,IAAI,IAAI,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBACzB,OAAO;YACR,CAAC;YAED,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"interceptXHR.js","sourceRoot":"","sources":["../src/interceptXHR.ts"],"names":[],"mappings":"AAAA,MAAM,YAAY,GAAG,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC;AAEnD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAwB,EAAE,OAAsC,EAAE,EAAE;IAChG,cAAc,CAAC,SAAS,CAAC,IAAI,GAAG,UAAU,IAAI;QAC7C,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE;YAClC,IAAI,IAAI,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBACzB,OAAO;YACR,CAAC;YAED,MAAM,OAAO,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAElH,IAAI,CAAC,OAAO,EAAE,CAAC;gBACd,OAAO;YACR,CAAC;YAED,OAAO,CAAC,IAAI,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;QACH,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC,CAAC;AACH,CAAC,CAAC"}
|
package/package.json
CHANGED