@sapphire-sh/utils 1.56.0 → 1.58.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-init.js +48 -0
- package/lib/esm/vitest.d.ts +3 -0
- package/lib/esm/vitest.d.ts.map +1 -0
- package/lib/esm/vitest.js +10 -0
- package/lib/esm/vitest.js.map +1 -0
- package/lib/vitest.d.ts +3 -0
- package/lib/vitest.d.ts.map +1 -0
- package/lib/vitest.js +12 -0
- package/lib/vitest.js.map +1 -0
- package/package.json +17 -2
- package/templates/.editorconfig +13 -0
- package/templates/.prettierignore +2 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { copyFileSync, existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const START_MARKER = '# sapphire-init:start';
|
|
8
|
+
const END_MARKER = '# sapphire-init:end';
|
|
9
|
+
|
|
10
|
+
const sectioned = new Set(['.gitignore']);
|
|
11
|
+
|
|
12
|
+
const templatesDir = join(fileURLToPath(import.meta.url), '..', '..', 'templates');
|
|
13
|
+
const cwd = process.cwd();
|
|
14
|
+
|
|
15
|
+
const writeSectioned = (filename, content) => {
|
|
16
|
+
const filepath = join(cwd, filename);
|
|
17
|
+
const section = `${START_MARKER}\n${content}${END_MARKER}`;
|
|
18
|
+
|
|
19
|
+
if (!existsSync(filepath)) {
|
|
20
|
+
writeFileSync(filepath, `${section}\n`);
|
|
21
|
+
console.log(`wrote ${filename}`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const existing = readFileSync(filepath, 'utf-8');
|
|
26
|
+
const startIndex = existing.indexOf(START_MARKER);
|
|
27
|
+
const endIndex = existing.indexOf(END_MARKER);
|
|
28
|
+
|
|
29
|
+
if (startIndex !== -1 && endIndex !== -1) {
|
|
30
|
+
const before = existing.slice(0, startIndex);
|
|
31
|
+
const after = existing.slice(endIndex + END_MARKER.length);
|
|
32
|
+
writeFileSync(filepath, `${before}${section}${after}`);
|
|
33
|
+
} else {
|
|
34
|
+
writeFileSync(filepath, `${section}\n\n${existing}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
console.log(`wrote ${filename}`);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
for (const filename of readdirSync(templatesDir)) {
|
|
41
|
+
if (sectioned.has(filename)) {
|
|
42
|
+
const content = readFileSync(join(templatesDir, filename), 'utf-8');
|
|
43
|
+
writeSectioned(filename, content);
|
|
44
|
+
} else {
|
|
45
|
+
copyFileSync(join(templatesDir, filename), join(cwd, filename));
|
|
46
|
+
console.log(`wrote ${filename}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../../src/vitest.ts"],"names":[],"mappings":";AAEA,wBAOG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest.js","sourceRoot":"","sources":["../../src/vitest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,eAAe,YAAY,CAAC;IAC3B,IAAI,EAAE;QACL,QAAQ,EAAE;YACT,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,CAAC,aAAa,CAAC;SACxB;KACD;CACD,CAAC,CAAC"}
|
package/lib/vitest.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":";AAEA,wBAOG"}
|
package/lib/vitest.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const config_1 = require("vitest/config");
|
|
4
|
+
exports.default = (0, config_1.defineConfig)({
|
|
5
|
+
test: {
|
|
6
|
+
coverage: {
|
|
7
|
+
provider: 'v8',
|
|
8
|
+
include: ['src/**/*.ts'],
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=vitest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest.js","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":";;AAAA,0CAA6C;AAE7C,kBAAe,IAAA,qBAAY,EAAC;IAC3B,IAAI,EAAE;QACL,QAAQ,EAAE;YACT,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,CAAC,aAAa,CAAC;SACxB;KACD;CACD,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sapphire-sh/utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.58.0",
|
|
4
4
|
"description": "@sapphire-sh/utils",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"sapphire-init": "./bin/sapphire-init.js"
|
|
10
|
+
},
|
|
8
11
|
"exports": {
|
|
9
12
|
".": {
|
|
10
13
|
"import": "./lib/esm/index.js",
|
|
@@ -21,17 +24,25 @@
|
|
|
21
24
|
"require": "./lib/prettier.js",
|
|
22
25
|
"types": "./lib/prettier.d.ts"
|
|
23
26
|
},
|
|
27
|
+
"./vitest": {
|
|
28
|
+
"import": "./lib/esm/vitest.js",
|
|
29
|
+
"require": "./lib/vitest.js",
|
|
30
|
+
"types": "./lib/vitest.d.ts"
|
|
31
|
+
},
|
|
24
32
|
"./tsconfig": "./tsconfig.json",
|
|
25
33
|
"./tsconfig.json": "./tsconfig.json",
|
|
26
34
|
"./tsconfig.esm": "./tsconfig.esm.json",
|
|
27
35
|
"./tsconfig.esm.json": "./tsconfig.esm.json"
|
|
28
36
|
},
|
|
29
37
|
"files": [
|
|
38
|
+
"bin/**/*",
|
|
30
39
|
"lib/**/*",
|
|
40
|
+
"templates/**/*",
|
|
31
41
|
"tsconfig.json",
|
|
32
42
|
"tsconfig.esm.json"
|
|
33
43
|
],
|
|
34
44
|
"scripts": {
|
|
45
|
+
"bootstrap": "node bin/sapphire-init.js",
|
|
35
46
|
"prebuild": "rm -fr ./lib",
|
|
36
47
|
"build": "tsc -p tsconfig.build.json && tsc -p tsconfig.build.esm.json && printf '{\"type\":\"module\"}' > lib/esm/package.json",
|
|
37
48
|
"prepare": "npm run build",
|
|
@@ -59,7 +70,8 @@
|
|
|
59
70
|
"eslint-plugin-promise": ">=7.0.0",
|
|
60
71
|
"prettier": ">=3.0.0",
|
|
61
72
|
"prettier-plugin-organize-imports": ">=4.0.0",
|
|
62
|
-
"typescript-eslint": ">=8.0.0"
|
|
73
|
+
"typescript-eslint": ">=8.0.0",
|
|
74
|
+
"vitest": ">=4.0.0"
|
|
63
75
|
},
|
|
64
76
|
"peerDependenciesMeta": {
|
|
65
77
|
"@eslint/js": {
|
|
@@ -76,6 +88,9 @@
|
|
|
76
88
|
},
|
|
77
89
|
"typescript-eslint": {
|
|
78
90
|
"optional": true
|
|
91
|
+
},
|
|
92
|
+
"vitest": {
|
|
93
|
+
"optional": true
|
|
79
94
|
}
|
|
80
95
|
},
|
|
81
96
|
"devDependencies": {
|