giget 0.1.2 → 0.1.5
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 +9 -15
- package/dist/cli.cjs +4 -3
- package/dist/cli.mjs +4 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +1 -1
- package/dist/shared/{giget.4b579418.mjs → giget.1430f5a2.mjs} +3 -2
- package/dist/shared/{giget.2ac4718b.cjs → giget.774476cb.cjs} +3 -2
- package/package.json +1 -1
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.
|
|
@@ -50,7 +43,7 @@ npx giget@latest gh:unjs/template my-lib
|
|
|
50
43
|
- `--no-registry`: Disable registry lookup and functionality.
|
|
51
44
|
- `--verbose`: Show verbose debugging info.
|
|
52
45
|
|
|
53
|
-
|
|
46
|
+
### Examples
|
|
54
47
|
|
|
55
48
|
```sh
|
|
56
49
|
# Clone the main branch of github.com/unjs/template to unjs-template directory
|
|
@@ -85,8 +78,9 @@ If you want to add your template to the built-in registry, just drop a PR to add
|
|
|
85
78
|
|
|
86
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).
|
|
87
80
|
|
|
88
|
-
- `name`: (required) Name of the template.
|
|
81
|
+
- `name`: (required) Name of the template.
|
|
89
82
|
- `tar` (required) Link to the tar download link.
|
|
83
|
+
- `defaultDir`: (optional) Default cloning directory.
|
|
90
84
|
- `url`: (optional) Webpage of the template.
|
|
91
85
|
- `subpath` (optional) Subpath inside the tar file.
|
|
92
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');
|
|
@@ -20,7 +20,8 @@ const mri__default = /*#__PURE__*/_interopDefaultLegacy(mri);
|
|
|
20
20
|
|
|
21
21
|
async function main() {
|
|
22
22
|
const args = mri__default(process.argv.slice(2), {
|
|
23
|
-
boolean: ["help", "force", "force-clean", "offline", "prefer-offline", "shell", "
|
|
23
|
+
boolean: ["help", "force", "force-clean", "offline", "prefer-offline", "shell", "verbose"],
|
|
24
|
+
string: ["registry"]
|
|
24
25
|
});
|
|
25
26
|
const input = args._[0];
|
|
26
27
|
const dir = args._[1];
|
|
@@ -38,7 +39,7 @@ async function main() {
|
|
|
38
39
|
offline: args.offline,
|
|
39
40
|
registry: args.registry
|
|
40
41
|
});
|
|
41
|
-
console.log(`\u2728 Successfully cloned ${colorette.cyan(r.url)} to ${colorette.cyan(node_path.relative(process.cwd(), r.dir))}
|
|
42
|
+
console.log(`\u2728 Successfully cloned ${colorette.cyan(r.name || r.url)} to ${colorette.cyan(node_path.relative(process.cwd(), r.dir))}
|
|
42
43
|
`);
|
|
43
44
|
if (args.shell) {
|
|
44
45
|
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';
|
|
@@ -14,7 +14,8 @@ import 'node-fetch-native';
|
|
|
14
14
|
|
|
15
15
|
async function main() {
|
|
16
16
|
const args = mri(process.argv.slice(2), {
|
|
17
|
-
boolean: ["help", "force", "force-clean", "offline", "prefer-offline", "shell", "
|
|
17
|
+
boolean: ["help", "force", "force-clean", "offline", "prefer-offline", "shell", "verbose"],
|
|
18
|
+
string: ["registry"]
|
|
18
19
|
});
|
|
19
20
|
const input = args._[0];
|
|
20
21
|
const dir = args._[1];
|
|
@@ -32,7 +33,7 @@ async function main() {
|
|
|
32
33
|
offline: args.offline,
|
|
33
34
|
registry: args.registry
|
|
34
35
|
});
|
|
35
|
-
console.log(`\u2728 Successfully cloned ${cyan(r.url)} to ${cyan(relative(process.cwd(), r.dir))}
|
|
36
|
+
console.log(`\u2728 Successfully cloned ${cyan(r.name || r.url)} to ${cyan(relative(process.cwd(), r.dir))}
|
|
36
37
|
`);
|
|
37
38
|
if (args.shell) {
|
|
38
39
|
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';
|
|
@@ -130,8 +130,9 @@ async function downloadTemplate(input, opts = {}) {
|
|
|
130
130
|
const template = await Promise.resolve().then(() => provider(source)).catch((err) => {
|
|
131
131
|
throw new Error(`Failed to download template from ${providerName}: ${err.message}`);
|
|
132
132
|
});
|
|
133
|
-
template.name = template.name.replace(/[^a-
|
|
134
|
-
|
|
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);
|
|
135
136
|
if (opts.forceClean) {
|
|
136
137
|
await rm(extractPath, { recursive: true, force: true });
|
|
137
138
|
}
|
|
@@ -136,8 +136,9 @@ async function downloadTemplate(input, opts = {}) {
|
|
|
136
136
|
const template = await Promise.resolve().then(() => provider(source)).catch((err) => {
|
|
137
137
|
throw new Error(`Failed to download template from ${providerName}: ${err.message}`);
|
|
138
138
|
});
|
|
139
|
-
template.name = template.name.replace(/[^a-
|
|
140
|
-
|
|
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);
|
|
141
142
|
if (opts.forceClean) {
|
|
142
143
|
await promises.rm(extractPath, { recursive: true, force: true });
|
|
143
144
|
}
|