c12 1.0.0 → 1.1.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/dist/index.cjs +10 -9
- package/dist/index.mjs +10 -9
- package/package.json +12 -13
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
const node_fs = require('node:fs');
|
|
4
4
|
const pathe = require('pathe');
|
|
5
5
|
const dotenv = require('dotenv');
|
|
6
|
-
const
|
|
6
|
+
const promises = require('node:fs/promises');
|
|
7
|
+
const node_os = require('node:os');
|
|
7
8
|
const createJiti = require('jiti');
|
|
8
9
|
const rc9 = require('rc9');
|
|
9
10
|
const defu = require('defu');
|
|
@@ -204,16 +205,16 @@ async function resolveConfig(source, options) {
|
|
|
204
205
|
}
|
|
205
206
|
}
|
|
206
207
|
if (GIT_PREFIXES.some((prefix) => source.startsWith(prefix))) {
|
|
208
|
+
const { downloadTemplate } = await import('giget');
|
|
207
209
|
const url = new URL(source);
|
|
208
|
-
const subPath = url.pathname.split("/").slice(2).join("/");
|
|
209
210
|
const gitRepo = url.protocol + url.pathname.split("/").slice(0, 2).join("/");
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
await
|
|
216
|
-
source =
|
|
211
|
+
const name = gitRepo.replace(/[#/:@\\]/g, "_");
|
|
212
|
+
const tmpDir = process.env.XDG_CACHE_HOME ? pathe.resolve(process.env.XDG_CACHE_HOME, "c12", name) : pathe.resolve(node_os.homedir(), ".cache/c12", name);
|
|
213
|
+
if (node_fs.existsSync(tmpDir)) {
|
|
214
|
+
await promises.rmdir(tmpDir, { recursive: true });
|
|
215
|
+
}
|
|
216
|
+
const clonned = await downloadTemplate(source, { dir: tmpDir });
|
|
217
|
+
source = clonned.dir;
|
|
217
218
|
}
|
|
218
219
|
if (NPM_PACKAGE_RE.test(source)) {
|
|
219
220
|
try {
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { existsSync, promises } from 'node:fs';
|
|
2
2
|
import { resolve, extname, dirname } from 'pathe';
|
|
3
3
|
import * as dotenv from 'dotenv';
|
|
4
|
-
import
|
|
4
|
+
import { rmdir } from 'node:fs/promises';
|
|
5
|
+
import { homedir } from 'node:os';
|
|
5
6
|
import createJiti from 'jiti';
|
|
6
7
|
import * as rc9 from 'rc9';
|
|
7
8
|
import { defu } from 'defu';
|
|
@@ -188,16 +189,16 @@ async function resolveConfig(source, options) {
|
|
|
188
189
|
}
|
|
189
190
|
}
|
|
190
191
|
if (GIT_PREFIXES.some((prefix) => source.startsWith(prefix))) {
|
|
192
|
+
const { downloadTemplate } = await import('giget');
|
|
191
193
|
const url = new URL(source);
|
|
192
|
-
const subPath = url.pathname.split("/").slice(2).join("/");
|
|
193
194
|
const gitRepo = url.protocol + url.pathname.split("/").slice(0, 2).join("/");
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
await
|
|
200
|
-
source =
|
|
195
|
+
const name = gitRepo.replace(/[#/:@\\]/g, "_");
|
|
196
|
+
const tmpDir = process.env.XDG_CACHE_HOME ? resolve(process.env.XDG_CACHE_HOME, "c12", name) : resolve(homedir(), ".cache/c12", name);
|
|
197
|
+
if (existsSync(tmpDir)) {
|
|
198
|
+
await rmdir(tmpDir, { recursive: true });
|
|
199
|
+
}
|
|
200
|
+
const clonned = await downloadTemplate(source, { dir: tmpDir });
|
|
201
|
+
source = clonned.dir;
|
|
201
202
|
}
|
|
202
203
|
if (NPM_PACKAGE_RE.test(source)) {
|
|
203
204
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "c12",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Smart Config Loader",
|
|
5
5
|
"repository": "unjs/c12",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,23 +19,15 @@
|
|
|
19
19
|
"files": [
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "unbuild",
|
|
24
|
-
"dev": "vitest dev",
|
|
25
|
-
"lint": "eslint --ext .ts,.js,.mjs,.cjs .",
|
|
26
|
-
"prepack": "unbuild",
|
|
27
|
-
"release": "pnpm test && standard-version && git push --follow-tags && pnpm publish",
|
|
28
|
-
"test": "vitest run --coverage"
|
|
29
|
-
},
|
|
30
22
|
"dependencies": {
|
|
31
23
|
"defu": "^6.1.1",
|
|
32
24
|
"dotenv": "^16.0.3",
|
|
33
|
-
"
|
|
25
|
+
"giget": "^1.0.0",
|
|
34
26
|
"jiti": "^1.16.0",
|
|
35
27
|
"mlly": "^1.0.0",
|
|
36
28
|
"pathe": "^1.0.0",
|
|
37
29
|
"pkg-types": "^1.0.1",
|
|
38
|
-
"rc9": "^
|
|
30
|
+
"rc9": "^2.0.0"
|
|
39
31
|
},
|
|
40
32
|
"devDependencies": {
|
|
41
33
|
"@vitest/coverage-c8": "^0.25.2",
|
|
@@ -46,5 +38,12 @@
|
|
|
46
38
|
"unbuild": "^0.9.4",
|
|
47
39
|
"vitest": "^0.25.2"
|
|
48
40
|
},
|
|
49
|
-
"packageManager": "pnpm@7.16.0"
|
|
50
|
-
|
|
41
|
+
"packageManager": "pnpm@7.16.0",
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "unbuild",
|
|
44
|
+
"dev": "vitest dev",
|
|
45
|
+
"lint": "eslint --ext .ts,.js,.mjs,.cjs .",
|
|
46
|
+
"release": "pnpm test && standard-version && git push --follow-tags && pnpm publish",
|
|
47
|
+
"test": "vitest run --coverage"
|
|
48
|
+
}
|
|
49
|
+
}
|