Skip to content

Commit faffc0d

Browse files
committed
add template
1 parent 89289c0 commit faffc0d

3 files changed

Lines changed: 137 additions & 42 deletions

File tree

package.json

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,42 @@
33
"description": "vtex plugin template",
44
"version": "0.0.0",
55
"bugs": "https://github.com/vtex/cli-plugin-template/issues",
6-
"dependencies": {
7-
"@oclif/command": "^1",
8-
"@oclif/config": "^1",
9-
"tslib": "^1"
10-
},
11-
"devDependencies": {
12-
"@oclif/dev-cli": "^1",
13-
"@oclif/plugin-help": "^3",
14-
"@types/jest": "^26.0.3",
15-
"@types/node": "^14.0.14",
16-
"eslint": "^6.8.0",
17-
"eslint-config-oclif": "^3.1",
18-
"eslint-config-vtex": "^12.3.0",
19-
"globby": "^10",
20-
"husky": "^4.2.5",
21-
"jest": "^25.1.0",
22-
"lint-staged": "^10.2.11",
23-
"nodemon": "^2.0.2",
24-
"nodemon-notifier-cli": "https://github.com/Slessi/nodemon-notifier-cli.git",
25-
"prettier": "^2.0.1",
26-
"ts-jest": "^25.2.1",
27-
"ts-node": "^8",
28-
"typescript": "^3.8.2",
29-
"vtex": "^2.121.1"
30-
},
6+
"homepage": "https://github.com/vtex/cli-plugin-template",
7+
"repository": "vtex/cli-plugin-template",
8+
"license": "MIT",
319
"engines": {
32-
"node": ">=8.0.0"
10+
"node": ">=14"
3311
},
3412
"files": [
3513
"/build",
3614
"/npm-shrinkwrap.json",
3715
"/oclif.manifest.json",
3816
"/yarn.lock"
3917
],
40-
"homepage": "https://github.com/vtex/cli-plugin-template",
4118
"keywords": [
4219
"oclif-plugin"
4320
],
44-
"license": "MIT",
4521
"oclif": {
4622
"commands": "./build/commands",
4723
"bin": "vtex",
4824
"devPlugins": [
4925
"@oclif/plugin-help"
5026
]
5127
},
52-
"repository": "vtex/cli-plugin-template",
28+
"husky": {
29+
"hooks": {
30+
"pre-commit": "lint-staged"
31+
}
32+
},
33+
"lint-staged": {
34+
"*.{ts,js,tsx,jsx}": [
35+
"eslint --fix",
36+
"prettier --write"
37+
],
38+
"*.json": [
39+
"prettier --write"
40+
]
41+
},
5342
"scripts": {
5443
"build-clean": "rm -rf build",
5544
"build-incremental": "tsc --incremental",
@@ -67,18 +56,31 @@
6756
"version": "oclif-dev readme && git add README.md",
6857
"watch": "yarn build-clean && yarn nodemon"
6958
},
70-
"husky": {
71-
"hooks": {
72-
"pre-commit": "lint-staged"
73-
}
59+
"dependencies": {
60+
"@oclif/command": "^1",
61+
"@oclif/config": "^1",
62+
"node-localstorage": "^2.2.1",
63+
"tslib": "^1"
7464
},
75-
"lint-staged": {
76-
"*.{ts,js,tsx,jsx}": [
77-
"eslint --fix",
78-
"prettier --write"
79-
],
80-
"*.json": [
81-
"prettier --write"
82-
]
65+
"devDependencies": {
66+
"@oclif/dev-cli": "^1",
67+
"@oclif/plugin-help": "^3",
68+
"@types/jest": "^26.0.3",
69+
"@types/node": "^14.0.14",
70+
"@types/node-localstorage": "^1.3.0",
71+
"eslint": "^6.8.0",
72+
"eslint-config-oclif": "^3.1",
73+
"eslint-config-vtex": "^12.3.0",
74+
"globby": "^10",
75+
"husky": "^4.2.5",
76+
"jest": "^25.1.0",
77+
"lint-staged": "^10.2.11",
78+
"nodemon": "^2.0.2",
79+
"nodemon-notifier-cli": "https://github.com/Slessi/nodemon-notifier-cli.git",
80+
"prettier": "^2.0.1",
81+
"ts-jest": "^25.2.1",
82+
"ts-node": "^8",
83+
"typescript": "^3.8.2",
84+
"vtex": "^2.121.1"
8385
}
8486
}

src/commands/link.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { Command, flags } from '@oclif/command'
2+
import { LocalStorage } from 'node-localstorage'
3+
4+
// let index: number = 0
5+
export default class Link extends Command {
6+
private storage: LocalStorage = new LocalStorage('~/.config/faststore.confg')
7+
8+
public static description = 'The link command facilitates the wml link'
9+
10+
public static examples = [`$ cli link`]
11+
12+
public static flags = {
13+
help: flags.help({ char: 'h' }),
14+
// flag with a value (-n, --name=VALUE)
15+
// name: flags.string({ char: 'n', description: 'name to print' }),
16+
// // flag with no value (-f, --force)
17+
// force: flags.boolean({ char: 'f' }),
18+
verbose: flags.boolean({ char: 'v' }),
19+
}
20+
21+
public static args = [{ name: 'file' }]
22+
public static source: string
23+
private index = 0
24+
25+
public async run() {
26+
this.index += 1
27+
28+
console.log({ index: this.index })
29+
30+
const { args } = this.parse(Link)
31+
32+
if (!args.file) {
33+
Link.source = process.cwd()
34+
this.log(`added ${Link.source} as the source`)
35+
this.storage.setItem('source', Link.source)
36+
} else {
37+
this.log(`source: ${this.storage.getItem('source')}`)
38+
}
39+
// const name = flags.name ?? 'world'
40+
// this.log(`hello ${name} from ./src/commands/hello.ts`)
41+
// if (args.file && flags.force) {
42+
// this.log(`you input --force and --file: ${args.file}`)
43+
// }
44+
// const { exec } = require("child_process")
45+
46+
// let my_var: string = "help";
47+
48+
// exec(`wml --${my_var}`, (error: { message: any }, stdout: any, stderr: any) => {
49+
// if (error) {
50+
// console.log(`error: ${error.message}`)
51+
// return
52+
// }
53+
// if (stderr) {
54+
// console.log(`stderr: ${stderr}`)
55+
// return
56+
// }
57+
// console.log(`stdout: ${stdout}`)
58+
// })
59+
}
60+
}

yarn.lock

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,11 @@
819819
resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"
820820
integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==
821821

822+
"@types/events@*":
823+
version "3.0.0"
824+
resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"
825+
integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==
826+
822827
"@types/express-serve-static-core@*":
823828
version "4.17.9"
824829
resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.9.tgz#2d7b34dcfd25ec663c25c85d76608f8b249667f1"
@@ -981,6 +986,13 @@
981986
"@types/node" "*"
982987
form-data "^3.0.0"
983988

989+
"@types/node-localstorage@^1.3.0":
990+
version "1.3.0"
991+
resolved "https://registry.yarnpkg.com/@types/node-localstorage/-/node-localstorage-1.3.0.tgz#8341b89abd8ad00afcd3fa9242ed956b8f5ad32c"
992+
integrity sha512-9+s5CWGhkYitklhLgnbf4s5ncCEx0An2jhBuhvw/sh9WNQ+/WvNFkPLyLjXGy+Oeo8CjPl69oz6M2FzZH+KwWA==
993+
dependencies:
994+
"@types/events" "*"
995+
984996
"@types/node@*", "@types/node@^14.0.14":
985997
version "14.6.0"
986998
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.6.0.tgz#7d4411bf5157339337d7cff864d9ff45f177b499"
@@ -6585,6 +6597,13 @@ node-int64@^0.4.0:
65856597
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
65866598
integrity sha1-h6kGXNs1XTGC2PlM4RGIuCXGijs=
65876599

6600+
node-localstorage@^2.2.1:
6601+
version "2.2.1"
6602+
resolved "https://registry.yarnpkg.com/node-localstorage/-/node-localstorage-2.2.1.tgz#869723550a4883e426cb391d2df0b563a51c7c1c"
6603+
integrity sha512-vv8fJuOUCCvSPjDjBLlMqYMHob4aGjkmrkaE42/mZr0VT+ZAU10jRF8oTnX9+pgU9/vYJ8P7YT3Vd6ajkmzSCw==
6604+
dependencies:
6605+
write-file-atomic "^1.1.4"
6606+
65886607
node-modules-regexp@^1.0.0:
65896608
version "1.0.0"
65906609
resolved "https://registry.yarnpkg.com/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz#8d9dbe28964a4ac5712e9131642107c71e90ec40"
@@ -8031,6 +8050,11 @@ slice-ansi@^4.0.0:
80318050
astral-regex "^2.0.0"
80328051
is-fullwidth-code-point "^3.0.0"
80338052

8053+
slide@^1.1.5:
8054+
version "1.1.6"
8055+
resolved "https://registry.yarnpkg.com/slide/-/slide-1.1.6.tgz#56eb027d65b4d2dce6cb2e2d32c4d4afc9e1d707"
8056+
integrity sha1-VusCfWW00tzmyy4tMsTUr8nh1wc=
8057+
80348058
snapdragon-node@^2.0.1:
80358059
version "2.1.1"
80368060
resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b"
@@ -8185,7 +8209,7 @@ static-extend@^0.1.1, static-extend@^0.1.2:
81858209
define-property "^0.2.5"
81868210
object-copy "^0.1.0"
81878211

8188-
"stats-lite@github:vtex/node-stats-lite#dist":
8212+
stats-lite@vtex/node-stats-lite#dist:
81898213
version "2.2.0"
81908214
resolved "https://codeload.github.com/vtex/node-stats-lite/tar.gz/1b0d39cc41ef7aaecfd541191f877887a2044797"
81918215
dependencies:
@@ -9280,6 +9304,15 @@ wrappy@1:
92809304
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
92819305
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
92829306

9307+
write-file-atomic@^1.1.4:
9308+
version "1.3.4"
9309+
resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-1.3.4.tgz#f807a4f0b1d9e913ae7a48112e6cc3af1991b45f"
9310+
integrity sha1-+Aek8LHZ6ROuekgRLmzDrxmRtF8=
9311+
dependencies:
9312+
graceful-fs "^4.1.11"
9313+
imurmurhash "^0.1.4"
9314+
slide "^1.1.5"
9315+
92839316
write-file-atomic@^2.0.0:
92849317
version "2.4.3"
92859318
resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.4.3.tgz#1fd2e9ae1df3e75b8d8c367443c692d4ca81f481"

0 commit comments

Comments
 (0)