-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/cli tool #280
Merged
Merged
Feat/cli tool #280
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
8baa069
add CLI package
patzick 2a6f9b8
regenerate with typescript
patzick 2e8411b
linter
patzick 9c931bf
prepare files
patzick c960b09
first setup
patzick 0c6dabc
feat(cli): init nuxt project
patzick cf94e34
Merge remote-tracking branch 'origin/master' into feat/cli-tool
patzick 031478f
feat(cli): prepare init and dev commands to start project
patzick 62e81ae
Merge remote-tracking branch 'origin/master' into feat/cli-tool
patzick 9eb7e56
feat(cli): update packages with theme versions
patzick 12ca600
feat(cli): add config file for usage in templates
patzick 724f44b
feat(cli): progress info while generating project
patzick 825203e
Merge remote-tracking branch 'origin/master' into feat/cli-tool
patzick ade96ad
docs: update docs with information how to start with CLI
patzick 90b57fa
chore: link cli package for local usage
patzick 682aecc
chore: not collect coverage from cli
patzick eb207ae
feat(cli): nuxt output in console when running 'shopware-pwa dev'
patzick a9a25f6
chore: do not run typedoc inside cli
patzick b0dd5ff
fix: incorrect interfaces imports
patzick 9405b0d
Merge branch 'master' into feat/cli-tool
patzick 0ac8ea2
chore: dependency to compositoin-api
patzick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.DS_Store | ||
node_modules | ||
npm-debug.log | ||
coverage | ||
.nyc_output | ||
dist | ||
build | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2017 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const { system, filesystem } = require("gluegun"); | ||
|
||
const src = filesystem.path(__dirname, ".."); | ||
|
||
const cli = async cmd => | ||
system.run("node " + filesystem.path(src, "bin", "cli") + ` ${cmd}`); | ||
|
||
test("outputs version", async () => { | ||
const output = await cli("--version"); | ||
expect(output).toContain("0.0.1"); | ||
}); | ||
|
||
test("outputs help", async () => { | ||
const output = await cli("--help"); | ||
expect(output).toContain("0.0.1"); | ||
}); | ||
|
||
test("generates file", async () => { | ||
const output = await cli("generate foo"); | ||
|
||
expect(output).toContain("Generated file at models/foo-model.ts"); | ||
const foomodel = filesystem.read("models/foo-model.ts"); | ||
|
||
expect(foomodel).toContain(`module.exports = {`); | ||
expect(foomodel).toContain(`name: 'foo'`); | ||
|
||
// cleanup artifact | ||
filesystem.remove("models"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env node | ||
|
||
|
||
/* tslint:disable */ | ||
// check if we're running in dev mode | ||
var devMode = require('fs').existsSync(`${__dirname}/../src`) | ||
// or want to "force" running the compiled version with --compiled-build | ||
var wantsCompiled = process.argv.indexOf('--compiled-build') >= 0 | ||
|
||
if (wantsCompiled || !devMode) { | ||
// this runs from the compiled javascript source | ||
require(`${__dirname}/../build/cli`).run(process.argv) | ||
} else { | ||
// this runs from the typescript source (for dev only) | ||
// hook into ts-node so we can run typescript on the fly | ||
require('ts-node').register({ project: `${__dirname}/../tsconfig.json` }) | ||
// run the CLI with the current process arguments | ||
require(`${__dirname}/../src/cli`).run(process.argv) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"name": "@shopware-pwa/cli", | ||
"version": "0.0.1", | ||
"description": "Shopware PWA CLI", | ||
"private": true, | ||
"types": "build/types/types.d.ts", | ||
"bin": { | ||
"shopware-pwa": "bin/shopware-pwa" | ||
}, | ||
"scripts": { | ||
"format": "prettier --write **/*.{js,ts,tsx,json}", | ||
"lint": "tslint -p .", | ||
"clean-build": "rm -rf ./build", | ||
"compile": "tsc -p .", | ||
"copy-templates": "if [ -e ./src/templates ]; then cp -a ./src/templates ./build/; fi", | ||
"build": "yarn format && yarn lint && yarn clean-build && yarn compile && yarn copy-templates", | ||
"prepublishOnly": "yarn build", | ||
"test": "jest", | ||
"watch": "jest --watch", | ||
"snapupdate": "jest --updateSnapshot", | ||
"coverage": "jest --coverage" | ||
}, | ||
"files": [ | ||
"tsconfig.json", | ||
"tslint.json", | ||
"build", | ||
"LICENSE", | ||
"readme.md", | ||
"docs", | ||
"bin" | ||
], | ||
"license": "MIT", | ||
"dependencies": { | ||
"gluegun": "^4.1.2" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^12.7.11", | ||
"@types/jest": "^24.0.18", | ||
"ts-node": "^8.4.1", | ||
"ts-jest": "^24.1.0", | ||
"tslint": "^5.12.0", | ||
"tslint-config-prettier": "^1.17.0", | ||
"tslint-config-standard": "^8.0.1", | ||
"typescript": "^3.6.3", | ||
"prettier": "^1.12.1", | ||
"jest": "^24.1.0" | ||
}, | ||
"jest": { | ||
"preset": "ts-jest", | ||
"testEnvironment": "node" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Shopware PWA CLI | ||
|
||
A CLI for Shopware PWA. | ||
|
||
## Customizing your CLI | ||
|
||
Check out the documentation at https://github.com/infinitered/gluegun/tree/master/docs. | ||
|
||
## Publishing to NPM | ||
|
||
To package your CLI up for NPM, do this: | ||
|
||
```shell | ||
$ npm login | ||
$ npm whoami | ||
$ npm lint | ||
$ npm test | ||
(if typescript, run `npm run build` here) | ||
$ npm publish | ||
``` | ||
|
||
# License | ||
|
||
MIT - see LICENSE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
shopwareEndpoint: "https://shopware-2.vuestorefront.io/sales-channel-api/v1", | ||
shopwareAccessToken: "SWSCMUDKAKHSRXPJEHNOSNHYAG" | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const { build } = require("gluegun"); | ||
|
||
/** | ||
* Create the cli and kick it off | ||
*/ | ||
async function run(argv) { | ||
// create a CLI runtime | ||
const cli = build() | ||
.brand("shopware-pwa") | ||
.src(__dirname) | ||
.plugins("./node_modules", { matching: "shopware-pwa-*", hidden: true }) | ||
.help() // provides default for help, h, --help, -h | ||
.version() // provides default for version, v, --version, -v | ||
.create(); | ||
// enable the following method if you'd like to skip loading one of these core extensions | ||
// this can improve performance if they're not necessary for your project: | ||
// .exclude(['meta', 'strings', 'print', 'filesystem', 'semver', 'system', 'prompt', 'http', 'template', 'patching']) | ||
// and run it | ||
const toolbox = await cli.run(argv); | ||
|
||
// send it back (for testing, mostly) | ||
return toolbox; | ||
} | ||
|
||
module.exports = { run }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { GluegunCommand } from "gluegun"; | ||
|
||
const command: GluegunCommand = { | ||
name: "cli", | ||
run: async toolbox => { | ||
const { print } = toolbox; | ||
|
||
print.info("Welcome to Shopware PWA CLI"); | ||
print.info("Explore your options typing: shopware-pwa --help"); | ||
} | ||
}; | ||
|
||
module.exports = command; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { GluegunCommand } from "gluegun"; | ||
|
||
const command: GluegunCommand = { | ||
name: "dev", | ||
run: async toolbox => { | ||
const { | ||
system: { spawn }, | ||
print: { info } | ||
} = toolbox; | ||
|
||
info(`Starting Shopware PWA development project...`); | ||
|
||
toolbox.themeFolders.forEach(themeFolder => | ||
toolbox.watchThemeFolder(themeFolder) | ||
); | ||
|
||
spawn("yarn dev", { | ||
stdio: "inherit" | ||
}); | ||
} | ||
}; | ||
|
||
module.exports = command; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { GluegunToolbox } from "gluegun"; | ||
|
||
module.exports = { | ||
name: "generate", | ||
alias: ["g"], | ||
run: async (toolbox: GluegunToolbox) => { | ||
const { | ||
parameters, | ||
template: { generate }, | ||
print: { info } | ||
} = toolbox; | ||
|
||
const name = parameters.first; | ||
|
||
await generate({ | ||
template: "model.ts.ejs", | ||
target: `models/${name}-model.ts`, | ||
props: { name } | ||
}); | ||
|
||
info(`Generated file at models/${name}-model.ts`); | ||
} | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it generates undefined-model.ts if no filename provided
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, it's just a showcase command, I will remove it later so I haven't mentioned it in documentation :)