This repository has been archived by the owner on Oct 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* add CLI package * feat(cli): init nuxt project * feat(cli): prepare init and dev commands to start project * feat(cli): update packages with theme versions * feat(cli): add config file for usage in templates * feat(cli): progress info while generating project * docs: update docs with information how to start with CLI * chore: do not run typedoc inside cli * fix: incorrect interfaces imports
- Loading branch information
Showing
32 changed files
with
1,026 additions
and
92 deletions.
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.
960ed22
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.
Deploy preview for website ready!
Built with commit 89038dd
https://shopware-pwa-p5ly78vzi.now.sh