giget 0.1.1 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -15
- package/dist/cli.cjs +9 -4
- package/dist/cli.mjs +9 -4
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +1 -1
- package/dist/shared/{giget.9c9971fe.mjs → giget.1430f5a2.mjs} +6 -2
- package/dist/shared/{giget.971c96e2.cjs → giget.774476cb.cjs} +6 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
✔ Support popular git providers (GitHub, GitLab, and Bitbucket) out of the box.
|
|
13
13
|
|
|
14
|
-
✔ Built-in and custom template registry.
|
|
14
|
+
✔ Built-in and custom [template registry](#template-registry).
|
|
15
15
|
|
|
16
16
|
✔ Fast cloning using tarball gzip without depending on local `git` and `tar`.
|
|
17
17
|
|
|
@@ -24,22 +24,15 @@
|
|
|
24
24
|
## Usage (CLI)
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
|
-
npx giget@latest <
|
|
27
|
+
npx giget@latest <template> [<dir>] [...options]
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
npx giget@latest gh:unjs/template my-lib
|
|
32
|
-
# ✨ Successfully cloned https://github.com/unjs/template/tree/main/ to my-lib
|
|
33
|
-
```
|
|
30
|
+
### Arguments
|
|
34
31
|
|
|
35
|
-
**
|
|
32
|
+
- **template**: Template name or a a URI describing provider, repository, subdir, and branch/ref. (See [Examples](#examples))
|
|
33
|
+
- **dir**: A relative or absolute path where to extract the template.
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
- Format is `[provider]:repo[/subpath][#ref]`.
|
|
39
|
-
- **dir**: A relative or absolute path where to extract the repository.
|
|
40
|
-
- If not provided, the name of the org + repo will be used as the name.
|
|
41
|
-
|
|
42
|
-
**Options:**
|
|
35
|
+
### Options
|
|
43
36
|
|
|
44
37
|
- `--force`: Clone to exsiting directory even if exists.
|
|
45
38
|
- `--offline`: Do not attempt to download and use cached version.
|
|
@@ -48,8 +41,9 @@ npx giget@latest gh:unjs/template my-lib
|
|
|
48
41
|
- `--shell`: ⚠️ Open a new shell with current working directory in cloned dir. (Experimental).
|
|
49
42
|
- `--registry`: URL to a custom registry.
|
|
50
43
|
- `--no-registry`: Disable registry lookup and functionality.
|
|
44
|
+
- `--verbose`: Show verbose debugging info.
|
|
51
45
|
|
|
52
|
-
|
|
46
|
+
### Examples
|
|
53
47
|
|
|
54
48
|
```sh
|
|
55
49
|
# Clone the main branch of github.com/unjs/template to unjs-template directory
|
|
@@ -84,8 +78,9 @@ If you want to add your template to the built-in registry, just drop a PR to add
|
|
|
84
78
|
|
|
85
79
|
A custom registry should provide an endpoint with dynamic path `/:template.json` that returns a JSON response with keys same as [custom providers](#custom-providers).
|
|
86
80
|
|
|
87
|
-
- `name`: (required) Name of the template.
|
|
81
|
+
- `name`: (required) Name of the template.
|
|
88
82
|
- `tar` (required) Link to the tar download link.
|
|
83
|
+
- `defaultDir`: (optional) Default cloning directory.
|
|
89
84
|
- `url`: (optional) Webpage of the template.
|
|
90
85
|
- `subpath` (optional) Subpath inside the tar file.
|
|
91
86
|
|
package/dist/cli.cjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
const node_path = require('node:path');
|
|
5
5
|
const mri = require('mri');
|
|
6
6
|
const colorette = require('colorette');
|
|
7
|
-
const giget = require('./shared/giget.
|
|
7
|
+
const giget = require('./shared/giget.774476cb.cjs');
|
|
8
8
|
require('node:fs/promises');
|
|
9
9
|
require('node:os');
|
|
10
10
|
require('node:fs');
|
|
@@ -19,13 +19,18 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
19
19
|
const mri__default = /*#__PURE__*/_interopDefaultLegacy(mri);
|
|
20
20
|
|
|
21
21
|
async function main() {
|
|
22
|
-
const args = mri__default(process.argv.slice(2)
|
|
22
|
+
const args = mri__default(process.argv.slice(2), {
|
|
23
|
+
boolean: ["help", "force", "force-clean", "offline", "prefer-offline", "shell", "registry", "verbose"]
|
|
24
|
+
});
|
|
23
25
|
const input = args._[0];
|
|
24
26
|
const dir = args._[1];
|
|
25
27
|
if (!input || args.help || args.h) {
|
|
26
|
-
console.error("Usage: npx getgit@latest <input> [<dir>] [--force] [--force-clean] [--offline] [--prefer-offline] [--shell] [--registry]
|
|
28
|
+
console.error("Usage: npx getgit@latest <input> [<dir>] [--force] [--force-clean] [--offline] [--prefer-offline] [--shell] [--registry] [--no-registry] [--verbose]");
|
|
27
29
|
process.exit(1);
|
|
28
30
|
}
|
|
31
|
+
if (args.verbose) {
|
|
32
|
+
process.env.DEBUG = process.env.DEBUG || "true";
|
|
33
|
+
}
|
|
29
34
|
const r = await giget.downloadTemplate(input, {
|
|
30
35
|
dir,
|
|
31
36
|
force: args.force,
|
|
@@ -33,7 +38,7 @@ async function main() {
|
|
|
33
38
|
offline: args.offline,
|
|
34
39
|
registry: args.registry
|
|
35
40
|
});
|
|
36
|
-
console.log(`\u2728 Successfully cloned ${colorette.cyan(r.url)} to ${colorette.cyan(node_path.relative(process.cwd(), r.dir))}
|
|
41
|
+
console.log(`\u2728 Successfully cloned ${colorette.cyan(r.name || r.url)} to ${colorette.cyan(node_path.relative(process.cwd(), r.dir))}
|
|
37
42
|
`);
|
|
38
43
|
if (args.shell) {
|
|
39
44
|
giget.startShell(r.dir);
|
package/dist/cli.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { relative } from 'node:path';
|
|
3
3
|
import mri from 'mri';
|
|
4
4
|
import { cyan } from 'colorette';
|
|
5
|
-
import { d as downloadTemplate, s as startShell } from './shared/giget.
|
|
5
|
+
import { d as downloadTemplate, s as startShell } from './shared/giget.1430f5a2.mjs';
|
|
6
6
|
import 'node:fs/promises';
|
|
7
7
|
import 'node:os';
|
|
8
8
|
import 'node:fs';
|
|
@@ -13,13 +13,18 @@ import 'node:child_process';
|
|
|
13
13
|
import 'node-fetch-native';
|
|
14
14
|
|
|
15
15
|
async function main() {
|
|
16
|
-
const args = mri(process.argv.slice(2)
|
|
16
|
+
const args = mri(process.argv.slice(2), {
|
|
17
|
+
boolean: ["help", "force", "force-clean", "offline", "prefer-offline", "shell", "registry", "verbose"]
|
|
18
|
+
});
|
|
17
19
|
const input = args._[0];
|
|
18
20
|
const dir = args._[1];
|
|
19
21
|
if (!input || args.help || args.h) {
|
|
20
|
-
console.error("Usage: npx getgit@latest <input> [<dir>] [--force] [--force-clean] [--offline] [--prefer-offline] [--shell] [--registry]
|
|
22
|
+
console.error("Usage: npx getgit@latest <input> [<dir>] [--force] [--force-clean] [--offline] [--prefer-offline] [--shell] [--registry] [--no-registry] [--verbose]");
|
|
21
23
|
process.exit(1);
|
|
22
24
|
}
|
|
25
|
+
if (args.verbose) {
|
|
26
|
+
process.env.DEBUG = process.env.DEBUG || "true";
|
|
27
|
+
}
|
|
23
28
|
const r = await downloadTemplate(input, {
|
|
24
29
|
dir,
|
|
25
30
|
force: args.force,
|
|
@@ -27,7 +32,7 @@ async function main() {
|
|
|
27
32
|
offline: args.offline,
|
|
28
33
|
registry: args.registry
|
|
29
34
|
});
|
|
30
|
-
console.log(`\u2728 Successfully cloned ${cyan(r.url)} to ${cyan(relative(process.cwd(), r.dir))}
|
|
35
|
+
console.log(`\u2728 Successfully cloned ${cyan(r.name || r.url)} to ${cyan(relative(process.cwd(), r.dir))}
|
|
31
36
|
`);
|
|
32
37
|
if (args.shell) {
|
|
33
38
|
startShell(r.dir);
|
package/dist/index.cjs
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ interface TemplateInfo {
|
|
|
10
10
|
version?: string;
|
|
11
11
|
subdir?: string;
|
|
12
12
|
url?: string;
|
|
13
|
+
defaultDir?: string;
|
|
13
14
|
source?: never;
|
|
14
15
|
dir?: never;
|
|
15
16
|
[key: string]: any;
|
|
@@ -34,6 +35,7 @@ declare function downloadTemplate(input: string, opts?: DownloadTemplateOptions)
|
|
|
34
35
|
version?: string;
|
|
35
36
|
subdir?: string;
|
|
36
37
|
url?: string;
|
|
38
|
+
defaultDir?: string;
|
|
37
39
|
}>;
|
|
38
40
|
|
|
39
41
|
declare const registryProvider: (registryEndpoint?: string) => TemplateProvider;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { d as downloadTemplate, r as registryProvider, s as startShell } from './shared/giget.
|
|
1
|
+
export { d as downloadTemplate, r as registryProvider, s as startShell } from './shared/giget.1430f5a2.mjs';
|
|
2
2
|
import 'node:fs/promises';
|
|
3
3
|
import 'node:os';
|
|
4
4
|
import 'node:fs';
|
|
@@ -63,6 +63,7 @@ const github = (input) => {
|
|
|
63
63
|
return {
|
|
64
64
|
name: parsed.repo.replace("/", "-"),
|
|
65
65
|
version: parsed.ref,
|
|
66
|
+
subdir: parsed.subdir,
|
|
66
67
|
url: `https://github.com/${parsed.repo}/tree/${parsed.ref}${parsed.subdir}`,
|
|
67
68
|
tar: `https://github.com/${parsed.repo}/archive/${parsed.ref}.tar.gz`
|
|
68
69
|
};
|
|
@@ -72,6 +73,7 @@ const gitlab = (input) => {
|
|
|
72
73
|
return {
|
|
73
74
|
name: parsed.repo.replace("/", "-"),
|
|
74
75
|
version: parsed.ref,
|
|
76
|
+
subdir: parsed.subdir,
|
|
75
77
|
url: `https://gitlab.com/${parsed.repo}/tree/${parsed.ref}${parsed.subdir}`,
|
|
76
78
|
tar: `https://gitlab.com/${parsed.repo}/-/archive/${parsed.ref}.tar.gz`
|
|
77
79
|
};
|
|
@@ -81,6 +83,7 @@ const bitbucket = (input) => {
|
|
|
81
83
|
return {
|
|
82
84
|
name: parsed.repo.replace("/", "-"),
|
|
83
85
|
version: parsed.ref,
|
|
86
|
+
subdir: parsed.subdir,
|
|
84
87
|
url: `https://bitbucket.com/${parsed.repo}/src/${parsed.ref}${parsed.subdir}`,
|
|
85
88
|
tar: `https://bitbucket.org/${parsed.repo}/get/${parsed.ref}.tar.gz`
|
|
86
89
|
};
|
|
@@ -127,8 +130,9 @@ async function downloadTemplate(input, opts = {}) {
|
|
|
127
130
|
const template = await Promise.resolve().then(() => provider(source)).catch((err) => {
|
|
128
131
|
throw new Error(`Failed to download template from ${providerName}: ${err.message}`);
|
|
129
132
|
});
|
|
130
|
-
template.name = template.name.replace(/[^a-
|
|
131
|
-
|
|
133
|
+
template.name = (template.name || "template").replace(/[^a-z0-9-]/gi, "-");
|
|
134
|
+
template.defaultDir = (template.defaultDir || template.name).replace(/[^a-z0-9-]/gi, "-");
|
|
135
|
+
const extractPath = resolve(opts.dir || template.defaultDir);
|
|
132
136
|
if (opts.forceClean) {
|
|
133
137
|
await rm(extractPath, { recursive: true, force: true });
|
|
134
138
|
}
|
|
@@ -69,6 +69,7 @@ const github = (input) => {
|
|
|
69
69
|
return {
|
|
70
70
|
name: parsed.repo.replace("/", "-"),
|
|
71
71
|
version: parsed.ref,
|
|
72
|
+
subdir: parsed.subdir,
|
|
72
73
|
url: `https://github.com/${parsed.repo}/tree/${parsed.ref}${parsed.subdir}`,
|
|
73
74
|
tar: `https://github.com/${parsed.repo}/archive/${parsed.ref}.tar.gz`
|
|
74
75
|
};
|
|
@@ -78,6 +79,7 @@ const gitlab = (input) => {
|
|
|
78
79
|
return {
|
|
79
80
|
name: parsed.repo.replace("/", "-"),
|
|
80
81
|
version: parsed.ref,
|
|
82
|
+
subdir: parsed.subdir,
|
|
81
83
|
url: `https://gitlab.com/${parsed.repo}/tree/${parsed.ref}${parsed.subdir}`,
|
|
82
84
|
tar: `https://gitlab.com/${parsed.repo}/-/archive/${parsed.ref}.tar.gz`
|
|
83
85
|
};
|
|
@@ -87,6 +89,7 @@ const bitbucket = (input) => {
|
|
|
87
89
|
return {
|
|
88
90
|
name: parsed.repo.replace("/", "-"),
|
|
89
91
|
version: parsed.ref,
|
|
92
|
+
subdir: parsed.subdir,
|
|
90
93
|
url: `https://bitbucket.com/${parsed.repo}/src/${parsed.ref}${parsed.subdir}`,
|
|
91
94
|
tar: `https://bitbucket.org/${parsed.repo}/get/${parsed.ref}.tar.gz`
|
|
92
95
|
};
|
|
@@ -133,8 +136,9 @@ async function downloadTemplate(input, opts = {}) {
|
|
|
133
136
|
const template = await Promise.resolve().then(() => provider(source)).catch((err) => {
|
|
134
137
|
throw new Error(`Failed to download template from ${providerName}: ${err.message}`);
|
|
135
138
|
});
|
|
136
|
-
template.name = template.name.replace(/[^a-
|
|
137
|
-
|
|
139
|
+
template.name = (template.name || "template").replace(/[^a-z0-9-]/gi, "-");
|
|
140
|
+
template.defaultDir = (template.defaultDir || template.name).replace(/[^a-z0-9-]/gi, "-");
|
|
141
|
+
const extractPath = pathe.resolve(opts.dir || template.defaultDir);
|
|
138
142
|
if (opts.forceClean) {
|
|
139
143
|
await promises.rm(extractPath, { recursive: true, force: true });
|
|
140
144
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "giget",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Download templates and git repositories with pleasure!",
|
|
5
5
|
"repository": "unjs/giget",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"dev": "vitest dev",
|
|
47
47
|
"giget": "jiti ./src/cli.ts",
|
|
48
48
|
"lint": "eslint --ext .ts,.js,.mjs,.cjs .",
|
|
49
|
-
"play": "
|
|
49
|
+
"play": "pnpm giget --force-clean --verbose unjs .tmp/clone",
|
|
50
50
|
"release": "pnpm test && standard-version && git push --follow-tags && pnpm publish",
|
|
51
51
|
"test": "pnpm lint && vitest run --coverage"
|
|
52
52
|
}
|