From faffc0d822116cfdaee71ea697f8639523f51b46 Mon Sep 17 00:00:00 2001 From: Tiago Gimenes Date: Thu, 1 Jul 2021 18:07:04 -0300 Subject: [PATCH 1/2] add template --- package.json | 84 +++++++++++++++++++++++--------------------- src/commands/link.ts | 60 +++++++++++++++++++++++++++++++ yarn.lock | 35 +++++++++++++++++- 3 files changed, 137 insertions(+), 42 deletions(-) create mode 100644 src/commands/link.ts diff --git a/package.json b/package.json index a07bc02..b4267fd 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,11 @@ "description": "vtex plugin template", "version": "0.0.0", "bugs": "https://github.com/vtex/cli-plugin-template/issues", - "dependencies": { - "@oclif/command": "^1", - "@oclif/config": "^1", - "tslib": "^1" - }, - "devDependencies": { - "@oclif/dev-cli": "^1", - "@oclif/plugin-help": "^3", - "@types/jest": "^26.0.3", - "@types/node": "^14.0.14", - "eslint": "^6.8.0", - "eslint-config-oclif": "^3.1", - "eslint-config-vtex": "^12.3.0", - "globby": "^10", - "husky": "^4.2.5", - "jest": "^25.1.0", - "lint-staged": "^10.2.11", - "nodemon": "^2.0.2", - "nodemon-notifier-cli": "https://github.com/Slessi/nodemon-notifier-cli.git", - "prettier": "^2.0.1", - "ts-jest": "^25.2.1", - "ts-node": "^8", - "typescript": "^3.8.2", - "vtex": "^2.121.1" - }, + "homepage": "https://github.com/vtex/cli-plugin-template", + "repository": "vtex/cli-plugin-template", + "license": "MIT", "engines": { - "node": ">=8.0.0" + "node": ">=14" }, "files": [ "/build", @@ -37,11 +15,9 @@ "/oclif.manifest.json", "/yarn.lock" ], - "homepage": "https://github.com/vtex/cli-plugin-template", "keywords": [ "oclif-plugin" ], - "license": "MIT", "oclif": { "commands": "./build/commands", "bin": "vtex", @@ -49,7 +25,20 @@ "@oclif/plugin-help" ] }, - "repository": "vtex/cli-plugin-template", + "husky": { + "hooks": { + "pre-commit": "lint-staged" + } + }, + "lint-staged": { + "*.{ts,js,tsx,jsx}": [ + "eslint --fix", + "prettier --write" + ], + "*.json": [ + "prettier --write" + ] + }, "scripts": { "build-clean": "rm -rf build", "build-incremental": "tsc --incremental", @@ -67,18 +56,31 @@ "version": "oclif-dev readme && git add README.md", "watch": "yarn build-clean && yarn nodemon" }, - "husky": { - "hooks": { - "pre-commit": "lint-staged" - } + "dependencies": { + "@oclif/command": "^1", + "@oclif/config": "^1", + "node-localstorage": "^2.2.1", + "tslib": "^1" }, - "lint-staged": { - "*.{ts,js,tsx,jsx}": [ - "eslint --fix", - "prettier --write" - ], - "*.json": [ - "prettier --write" - ] + "devDependencies": { + "@oclif/dev-cli": "^1", + "@oclif/plugin-help": "^3", + "@types/jest": "^26.0.3", + "@types/node": "^14.0.14", + "@types/node-localstorage": "^1.3.0", + "eslint": "^6.8.0", + "eslint-config-oclif": "^3.1", + "eslint-config-vtex": "^12.3.0", + "globby": "^10", + "husky": "^4.2.5", + "jest": "^25.1.0", + "lint-staged": "^10.2.11", + "nodemon": "^2.0.2", + "nodemon-notifier-cli": "https://github.com/Slessi/nodemon-notifier-cli.git", + "prettier": "^2.0.1", + "ts-jest": "^25.2.1", + "ts-node": "^8", + "typescript": "^3.8.2", + "vtex": "^2.121.1" } } diff --git a/src/commands/link.ts b/src/commands/link.ts new file mode 100644 index 0000000..d859795 --- /dev/null +++ b/src/commands/link.ts @@ -0,0 +1,60 @@ +import { Command, flags } from '@oclif/command' +import { LocalStorage } from 'node-localstorage' + +// let index: number = 0 +export default class Link extends Command { + private storage: LocalStorage = new LocalStorage('~/.config/faststore.confg') + + public static description = 'The link command facilitates the wml link' + + public static examples = [`$ cli link`] + + public static flags = { + help: flags.help({ char: 'h' }), + // flag with a value (-n, --name=VALUE) + // name: flags.string({ char: 'n', description: 'name to print' }), + // // flag with no value (-f, --force) + // force: flags.boolean({ char: 'f' }), + verbose: flags.boolean({ char: 'v' }), + } + + public static args = [{ name: 'file' }] + public static source: string + private index = 0 + + public async run() { + this.index += 1 + + console.log({ index: this.index }) + + const { args } = this.parse(Link) + + if (!args.file) { + Link.source = process.cwd() + this.log(`added ${Link.source} as the source`) + this.storage.setItem('source', Link.source) + } else { + this.log(`source: ${this.storage.getItem('source')}`) + } + // const name = flags.name ?? 'world' + // this.log(`hello ${name} from ./src/commands/hello.ts`) + // if (args.file && flags.force) { + // this.log(`you input --force and --file: ${args.file}`) + // } + // const { exec } = require("child_process") + + // let my_var: string = "help"; + + // exec(`wml --${my_var}`, (error: { message: any }, stdout: any, stderr: any) => { + // if (error) { + // console.log(`error: ${error.message}`) + // return + // } + // if (stderr) { + // console.log(`stderr: ${stderr}`) + // return + // } + // console.log(`stdout: ${stdout}`) + // }) + } +} diff --git a/yarn.lock b/yarn.lock index d9d3610..dac26a2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -819,6 +819,11 @@ resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag== +"@types/events@*": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7" + integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g== + "@types/express-serve-static-core@*": version "4.17.9" resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.9.tgz#2d7b34dcfd25ec663c25c85d76608f8b249667f1" @@ -981,6 +986,13 @@ "@types/node" "*" form-data "^3.0.0" +"@types/node-localstorage@^1.3.0": + version "1.3.0" + resolved "https://registry.yarnpkg.com/@types/node-localstorage/-/node-localstorage-1.3.0.tgz#8341b89abd8ad00afcd3fa9242ed956b8f5ad32c" + integrity sha512-9+s5CWGhkYitklhLgnbf4s5ncCEx0An2jhBuhvw/sh9WNQ+/WvNFkPLyLjXGy+Oeo8CjPl69oz6M2FzZH+KwWA== + dependencies: + "@types/events" "*" + "@types/node@*", "@types/node@^14.0.14": version "14.6.0" resolved "https://registry.yarnpkg.com/@types/node/-/node-14.6.0.tgz#7d4411bf5157339337d7cff864d9ff45f177b499" @@ -6585,6 +6597,13 @@ node-int64@^0.4.0: resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" integrity sha1-h6kGXNs1XTGC2PlM4RGIuCXGijs= +node-localstorage@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/node-localstorage/-/node-localstorage-2.2.1.tgz#869723550a4883e426cb391d2df0b563a51c7c1c" + integrity sha512-vv8fJuOUCCvSPjDjBLlMqYMHob4aGjkmrkaE42/mZr0VT+ZAU10jRF8oTnX9+pgU9/vYJ8P7YT3Vd6ajkmzSCw== + dependencies: + write-file-atomic "^1.1.4" + node-modules-regexp@^1.0.0: version "1.0.0" 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: astral-regex "^2.0.0" is-fullwidth-code-point "^3.0.0" +slide@^1.1.5: + version "1.1.6" + resolved "https://registry.yarnpkg.com/slide/-/slide-1.1.6.tgz#56eb027d65b4d2dce6cb2e2d32c4d4afc9e1d707" + integrity sha1-VusCfWW00tzmyy4tMsTUr8nh1wc= + snapdragon-node@^2.0.1: version "2.1.1" 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: define-property "^0.2.5" object-copy "^0.1.0" -"stats-lite@github:vtex/node-stats-lite#dist": +stats-lite@vtex/node-stats-lite#dist: version "2.2.0" resolved "https://codeload.github.com/vtex/node-stats-lite/tar.gz/1b0d39cc41ef7aaecfd541191f877887a2044797" dependencies: @@ -9280,6 +9304,15 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= +write-file-atomic@^1.1.4: + version "1.3.4" + resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-1.3.4.tgz#f807a4f0b1d9e913ae7a48112e6cc3af1991b45f" + integrity sha1-+Aek8LHZ6ROuekgRLmzDrxmRtF8= + dependencies: + graceful-fs "^4.1.11" + imurmurhash "^0.1.4" + slide "^1.1.5" + write-file-atomic@^2.0.0: version "2.4.3" resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.4.3.tgz#1fd2e9ae1df3e75b8d8c367443c692d4ca81f481" From bd218596938701dd61b1bc806b01f4421679c2e1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Jul 2021 21:08:21 +0000 Subject: [PATCH 2/2] Bump ws from 5.2.2 to 5.2.3 Bumps [ws](https://github.com/websockets/ws) from 5.2.2 to 5.2.3. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/5.2.2...5.2.3) --- updated-dependencies: - dependency-name: ws dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index dac26a2..89bf84b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9352,9 +9352,9 @@ write@1.0.3: mkdirp "^0.5.1" ws@^5.2.0: - version "5.2.2" - resolved "https://registry.yarnpkg.com/ws/-/ws-5.2.2.tgz#dffef14866b8e8dc9133582514d1befaf96e980f" - integrity sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA== + version "5.2.3" + resolved "https://registry.yarnpkg.com/ws/-/ws-5.2.3.tgz#05541053414921bc29c63bee14b8b0dd50b07b3d" + integrity sha512-jZArVERrMsKUatIdnLzqvcfydI85dvd/Fp1u/VOpfdDWQ4c9qWXe+VIeAbQ5FrDwciAkr+lzofXLz3Kuf26AOA== dependencies: async-limiter "~1.0.0"