@foxsell/cli 0.0.0-stage → 0.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/LICENSE +21 -0
- package/README.md +70 -2
- package/bin/dev.js +5 -0
- package/bin/run.js +5 -0
- package/dist/base/template-command.d.ts +11 -0
- package/dist/base/template-command.js +11 -0
- package/dist/commands/template/add.d.ts +8 -0
- package/dist/commands/template/add.js +42 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lib/template-repo.d.ts +17 -0
- package/dist/lib/template-repo.js +38 -0
- package/oclif.manifest.json +35 -0
- package/package.json +72 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Foxsell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,71 @@
|
|
|
1
|
-
|
|
1
|
+
@foxsell/cli
|
|
2
|
+
=================
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
Foxsell CLI
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
[](https://oclif.io)
|
|
8
|
+
[](https://npmjs.org/package/@foxsell/cli)
|
|
9
|
+
[](https://npmjs.org/package/@foxsell/cli)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
<!-- toc -->
|
|
13
|
+
* [Usage](#usage)
|
|
14
|
+
* [Commands](#commands)
|
|
15
|
+
<!-- tocstop -->
|
|
16
|
+
# Usage
|
|
17
|
+
<!-- usage -->
|
|
18
|
+
```sh-session
|
|
19
|
+
$ npm install -g @foxsell/cli
|
|
20
|
+
$ foxsell COMMAND
|
|
21
|
+
running command...
|
|
22
|
+
$ foxsell (--version)
|
|
23
|
+
@foxsell/cli/0.1.0 darwin-arm64 node-v24.22.3
|
|
24
|
+
$ foxsell --help [COMMAND]
|
|
25
|
+
USAGE
|
|
26
|
+
$ foxsell COMMAND
|
|
27
|
+
...
|
|
28
|
+
```
|
|
29
|
+
<!-- usagestop -->
|
|
30
|
+
# Commands
|
|
31
|
+
<!-- commands -->
|
|
32
|
+
* [`foxsell help [COMMAND]`](#foxsell-help-command)
|
|
33
|
+
* [`foxsell template add`](#foxsell-template-add)
|
|
34
|
+
|
|
35
|
+
## `foxsell help [COMMAND]`
|
|
36
|
+
|
|
37
|
+
Display help for foxsell.
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
USAGE
|
|
41
|
+
$ foxsell help [COMMAND...] [-n]
|
|
42
|
+
|
|
43
|
+
ARGUMENTS
|
|
44
|
+
[COMMAND...] Command to show help for.
|
|
45
|
+
|
|
46
|
+
FLAGS
|
|
47
|
+
-n, --nested-commands Include all nested commands in the output.
|
|
48
|
+
|
|
49
|
+
DESCRIPTION
|
|
50
|
+
Display help for foxsell.
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/6.3.0/src/commands/help.ts)_
|
|
54
|
+
|
|
55
|
+
## `foxsell template add`
|
|
56
|
+
|
|
57
|
+
Add a template
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
USAGE
|
|
61
|
+
$ foxsell template add [--path <value>]
|
|
62
|
+
|
|
63
|
+
FLAGS
|
|
64
|
+
--path=<value> [default: .] Path to add the template to
|
|
65
|
+
|
|
66
|
+
DESCRIPTION
|
|
67
|
+
Add a template
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
_See code: [src/commands/template/add.ts](https://github.com/FoxSellApp/foxsell-cli/blob/v0.1.0/src/commands/template/add.ts)_
|
|
71
|
+
<!-- commandsstop -->
|
package/bin/dev.js
ADDED
package/bin/run.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
/**
|
|
3
|
+
* Shared base class for all `template *` commands.
|
|
4
|
+
*
|
|
5
|
+
* Put logic/flags/args common to every `template` subcommand here
|
|
6
|
+
* (e.g. shared flags, auth, config loading) so new commands added
|
|
7
|
+
* under `src/commands/template/` can extend it instead of duplicating code.
|
|
8
|
+
*/
|
|
9
|
+
export default abstract class TemplateCommand extends Command {
|
|
10
|
+
static baseFlags: {};
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
/**
|
|
3
|
+
* Shared base class for all `template *` commands.
|
|
4
|
+
*
|
|
5
|
+
* Put logic/flags/args common to every `template` subcommand here
|
|
6
|
+
* (e.g. shared flags, auth, config loading) so new commands added
|
|
7
|
+
* under `src/commands/template/` can extend it instead of duplicating code.
|
|
8
|
+
*/
|
|
9
|
+
export default class TemplateCommand extends Command {
|
|
10
|
+
static baseFlags = {};
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import TemplateCommand from '../../base/template-command.js';
|
|
2
|
+
export default class TemplateAdd extends TemplateCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
path: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
};
|
|
7
|
+
run(): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { confirm, select } from '@inquirer/prompts';
|
|
2
|
+
import { Flags, ux } from '@oclif/core';
|
|
3
|
+
import TemplateCommand from '../../base/template-command.js';
|
|
4
|
+
import { addTemplate, isNonEmptyDir, listTemplates } from '../../lib/template-repo.js';
|
|
5
|
+
export default class TemplateAdd extends TemplateCommand {
|
|
6
|
+
static description = 'Add a template';
|
|
7
|
+
static flags = {
|
|
8
|
+
path: Flags.string({
|
|
9
|
+
default: '.',
|
|
10
|
+
description: 'Path to add the template to',
|
|
11
|
+
}),
|
|
12
|
+
};
|
|
13
|
+
async run() {
|
|
14
|
+
const { flags } = await this.parse(TemplateAdd);
|
|
15
|
+
ux.action.start('Fetching templates');
|
|
16
|
+
const templates = await listTemplates();
|
|
17
|
+
ux.action.stop();
|
|
18
|
+
if (templates.length === 0) {
|
|
19
|
+
this.error('No templates found in the repository.');
|
|
20
|
+
}
|
|
21
|
+
const template = await select({
|
|
22
|
+
choices: templates.map((name) => ({ name, value: name })),
|
|
23
|
+
message: 'Select a template',
|
|
24
|
+
});
|
|
25
|
+
let force = false;
|
|
26
|
+
if (await isNonEmptyDir(flags.path)) {
|
|
27
|
+
const overwrite = await confirm({
|
|
28
|
+
default: false,
|
|
29
|
+
message: `"${flags.path}" already has files in it. Overwrite conflicting files?`,
|
|
30
|
+
});
|
|
31
|
+
if (!overwrite) {
|
|
32
|
+
this.log('Cancelled.');
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
force = true;
|
|
36
|
+
}
|
|
37
|
+
ux.action.start(`Adding "${template}" to ${flags.path}`);
|
|
38
|
+
await addTemplate(template, flags.path, { force });
|
|
39
|
+
ux.action.stop();
|
|
40
|
+
this.log(`you selected the ${template} template, added to ${flags.path}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { run } from '@oclif/core';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { run } from '@oclif/core';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Templates repo on GitHub. Add/remove templates by adding/removing a
|
|
3
|
+
* folder under `templates/` in this repo — nothing here needs to change.
|
|
4
|
+
*
|
|
5
|
+
* https://github.com/FoxSellApp/foxkit-bundle-templates
|
|
6
|
+
*/
|
|
7
|
+
export declare const TEMPLATE_REPO = "FoxSellApp/foxkit-bundle-templates";
|
|
8
|
+
/** Files excluded when copying a template's contents into the destination. */
|
|
9
|
+
export declare const IGNORE: string[];
|
|
10
|
+
/** Lists the available template names found under `templates/` in the repo. */
|
|
11
|
+
export declare function listTemplates(): Promise<string[]>;
|
|
12
|
+
/** Whether `dir` exists and contains at least one entry. */
|
|
13
|
+
export declare function isNonEmptyDir(dir: string): Promise<boolean>;
|
|
14
|
+
/** Downloads `templates/<name>` from the repo directly into `destDir`. */
|
|
15
|
+
export declare function addTemplate(name: string, destDir: string, options: {
|
|
16
|
+
force: boolean;
|
|
17
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { promises as fs } from 'node:fs';
|
|
2
|
+
import { downloadTemplate } from 'giget';
|
|
3
|
+
/**
|
|
4
|
+
* Templates repo on GitHub. Add/remove templates by adding/removing a
|
|
5
|
+
* folder under `templates/` in this repo — nothing here needs to change.
|
|
6
|
+
*
|
|
7
|
+
* https://github.com/FoxSellApp/foxkit-bundle-templates
|
|
8
|
+
*/
|
|
9
|
+
export const TEMPLATE_REPO = 'FoxSellApp/foxkit-bundle-templates';
|
|
10
|
+
/** Files excluded when copying a template's contents into the destination. */
|
|
11
|
+
export const IGNORE = ['README.md', 'CHANGELOG.md'];
|
|
12
|
+
/** Lists the available template names found under `templates/` in the repo. */
|
|
13
|
+
export async function listTemplates() {
|
|
14
|
+
const response = await fetch(`https://api.github.com/repos/${TEMPLATE_REPO}/contents/templates`);
|
|
15
|
+
if (!response.ok) {
|
|
16
|
+
throw new Error(`Failed to list templates: ${response.status} ${response.statusText}`);
|
|
17
|
+
}
|
|
18
|
+
const entries = (await response.json());
|
|
19
|
+
return entries.filter((entry) => entry.type === 'dir').map((entry) => entry.name);
|
|
20
|
+
}
|
|
21
|
+
/** Whether `dir` exists and contains at least one entry. */
|
|
22
|
+
export async function isNonEmptyDir(dir) {
|
|
23
|
+
try {
|
|
24
|
+
const entries = await fs.readdir(dir);
|
|
25
|
+
return entries.length > 0;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** Downloads `templates/<name>` from the repo directly into `destDir`. */
|
|
32
|
+
export async function addTemplate(name, destDir, options) {
|
|
33
|
+
await downloadTemplate(`github:${TEMPLATE_REPO}/templates/${name}`, {
|
|
34
|
+
dir: destDir,
|
|
35
|
+
force: options.force,
|
|
36
|
+
ignore: IGNORE,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"commands": {
|
|
3
|
+
"template:add": {
|
|
4
|
+
"aliases": [],
|
|
5
|
+
"args": {},
|
|
6
|
+
"description": "Add a template",
|
|
7
|
+
"flags": {
|
|
8
|
+
"path": {
|
|
9
|
+
"description": "Path to add the template to",
|
|
10
|
+
"name": "path",
|
|
11
|
+
"default": ".",
|
|
12
|
+
"hasDynamicHelp": false,
|
|
13
|
+
"multiple": false,
|
|
14
|
+
"type": "option"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"hasDynamicHelp": false,
|
|
18
|
+
"hiddenAliases": [],
|
|
19
|
+
"id": "template:add",
|
|
20
|
+
"pluginAlias": "@foxsell/cli",
|
|
21
|
+
"pluginName": "@foxsell/cli",
|
|
22
|
+
"pluginType": "core",
|
|
23
|
+
"strict": true,
|
|
24
|
+
"enableJsonFlag": false,
|
|
25
|
+
"isESM": true,
|
|
26
|
+
"relativePath": [
|
|
27
|
+
"dist",
|
|
28
|
+
"commands",
|
|
29
|
+
"template",
|
|
30
|
+
"add.js"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"version": "0.1.0"
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,74 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foxsell/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Foxsell CLI",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Foxsell",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/FoxSellApp/foxsell-cli.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/FoxSellApp/foxsell-cli",
|
|
13
|
+
"bugs": "https://github.com/FoxSellApp/foxsell-cli/issues",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"foxsell",
|
|
16
|
+
"cli",
|
|
17
|
+
"oclif",
|
|
18
|
+
"shopify",
|
|
19
|
+
"templates"
|
|
20
|
+
],
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"bin": {
|
|
25
|
+
"foxsell": "./bin/run.js"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"/bin",
|
|
29
|
+
"/dist",
|
|
30
|
+
"/oclif.manifest.json"
|
|
31
|
+
],
|
|
32
|
+
"main": "dist/index.js",
|
|
33
|
+
"exports": "./dist/index.js",
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "shx rm -rf dist && tsc -b",
|
|
36
|
+
"clean": "shx rm -rf dist tmp oclif.manifest.json",
|
|
37
|
+
"postpack": "shx rm -f oclif.manifest.json",
|
|
38
|
+
"prepack": "npm run build && oclif manifest && oclif readme",
|
|
39
|
+
"dev": "./bin/dev.js",
|
|
40
|
+
"test": "echo NO TESTS YET"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@inquirer/prompts": "^8.8.0",
|
|
44
|
+
"@oclif/core": "^4",
|
|
45
|
+
"@oclif/plugin-help": "^6",
|
|
46
|
+
"giget": "^3.3.1"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/node": "^22",
|
|
50
|
+
"oclif": "^4",
|
|
51
|
+
"shx": "^0.3",
|
|
52
|
+
"typescript": "^5"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=20.17.0"
|
|
56
|
+
},
|
|
57
|
+
"oclif": {
|
|
58
|
+
"bin": "foxsell",
|
|
59
|
+
"dirname": "foxsell",
|
|
60
|
+
"additionalHelpFlags": [
|
|
61
|
+
"-h"
|
|
62
|
+
],
|
|
63
|
+
"commands": "./dist/commands",
|
|
64
|
+
"plugins": [
|
|
65
|
+
"@oclif/plugin-help"
|
|
66
|
+
],
|
|
67
|
+
"topicSeparator": " ",
|
|
68
|
+
"topics": {
|
|
69
|
+
"template": {
|
|
70
|
+
"description": "Manage templates"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|