Skip to content

Commit

Permalink
feat(packer-theme): Added id flag for theme:remove as an alternativ…
Browse files Browse the repository at this point in the history
…e to env values
  • Loading branch information
Eric Hayes committed Oct 8, 2020
1 parent 857742c commit 12b1fde
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Shopify development tool using themekit and webpack. Also a compatible replaceme
- Multiple entrypoints for templates and layouts
- List themes on store
- Delete themes from CLI
- Create new empty theme in Shopify from CLI, adds theme id to config.json
- Create new empty theme in Shopify from CLI, adds theme id to packer.config.json
- Download existing themes
- Download files/sync changes
- Init base packer theme from cli or use a custom github repo
Expand All @@ -86,7 +86,7 @@ yarn global add @hayes0724/shopify-packer
```
packer init <dirname>
```
2. Add app password and store url to config.json
2. Add app password and store url to packer.config.json

3. Create new empty theme on shopify
```
Expand Down Expand Up @@ -130,7 +130,7 @@ packer start [--env=my-custom-env-name] [--skipPrompts] [--skipFirstDeploy]

| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Flag &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | Description |
| --- | --- |
| `--env` | Targets a custom environment. Setting --env=production would use the production settings in config.json |
| `--env` | Targets a custom environment. Setting --env=production would use the production settings in packer.config.json |
| `--skipPrompts` | Skips all prompts. This is especially useful when using Packer with continuous integration tools |
| `--skipFirstDeploy` | Skips the file upload sequence and simply boots up the local Express server |

Expand All @@ -146,7 +146,7 @@ packer deploy [--env=my-custom-env-name] [--skipPrompts] [--replace]
```
| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Flag &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | Description |
| --- | --- |
| ``--env`` | Targets a custom environment. Setting --env=production would use the production settings in config.json |
| ``--env`` | Targets a custom environment. Setting --env=production would use the production settings in packer.config.json |
| ``--skipPrompts`` | Skips all prompts. This is especially useful when using Packer with continuous integration tools |
| ``--nodelete`` | By default deploy will replace all files in theme, use this flag to update without removing existing files |
### build
Expand Down Expand Up @@ -184,21 +184,21 @@ Compiles the contents of the dist directory and creates a ZIP file in the root o
packer zip
```
### theme:list
Lists all themes (shows name, themeID, etc...) on the site, requires app password and store url be set first. By default looks at the store for development env in config.json
Lists all themes (shows name, themeID, etc...) on the site, requires app password and store url be set first. By default looks at the store for development env in packer.config.json
```bash
packer theme:list
```
| Flag | Description |
| --- | --- |
| ``--env`` | Targets a custom environment. Setting --env=production would use the production settings in config.json |
| ``--env`` | Targets a custom environment. Setting --env=production would use the production settings in packer.config.json |
### theme:create
Creates a new empty theme on Shopify and updates config.json for the selected env with the proper themeID
Creates a new empty theme on Shopify and updates packer.config.json for the selected env with the proper themeID
```bash
packer theme:create
```
| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Flag &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | Description |
| --- | --- |
| ``--env`` | Targets a custom environment. Setting --env=production would use the production settings in config.json |
| ``--env`` | Targets a custom environment. Setting --env=production would use the production settings in packer.config.json |
| ``--name=my-theme-name `` | Sets the theme name on Shopify, it's required |
### theme:remove
Removes the theme set in the selected env from Shopify
Expand All @@ -207,7 +207,8 @@ packer theme:remove
```
| Flag | Description |
| --- | --- |
| ``--env`` | Targets a custom environment. Setting --env=production would use the production settings in config.json |
| ``--env`` | Targets a custom environment (defaults to development). Setting --env=production would use the production settings in packer.config.json |
| ``--id`` | Delete a theme by using its ID |

### theme:download
Downloads the theme set in the selected env from Shopify
Expand All @@ -216,7 +217,7 @@ packer theme:download
```
| Flag | Description |
| --- | --- |
| ``--env`` | Targets a custom environment. Setting --env=production would use the production settings in config.json |
| ``--env`` | Targets a custom environment. Setting --env=production would use the production settings in packer.config.json |


### help
Expand Down
7 changes: 4 additions & 3 deletions cli/commands/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,21 @@ module.exports = () => {
]);
commands.push([
chalk.greenBright.bold('theme:list'),
'Lists all themes on the store using credentials in config.json',
'Lists all themes on the store using credentials in packer.config.json',
'--env=my-custom-env-name',
]);
commands.push([
chalk.greenBright.bold('theme:create'),
'Create a new theme using credentials in config.json, it will add the store id to your config',
'Create a new theme using credentials in packer.config.json, it will add the store id to your config',
`--env=my-custom-env-name
--name=my-theme-name
--deploy`,
]);
commands.push([
chalk.greenBright.bold('theme:remove'),
'Completely deletes the theme using the id set in config.json',
'Completely deletes the theme using the id set in packer.config.json or by providing a id flag',
'--env=my-custom-env-name\n',
'--id=1234456789\n',
]);
commands.push([
chalk.greenBright.bold('theme:download'),
Expand Down
2 changes: 1 addition & 1 deletion cli/commands/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = async (args) => {
await createTheme(args);
}
if (args.remove) {
await removeTheme();
await removeTheme(args);
}
if (args.download) {
downloadTheme()
Expand Down
4 changes: 2 additions & 2 deletions src/theme/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ const create = (args) => {
});
};

const remove = async () => {
const remove = async (themeIdFlag = null) => {
_headers();
const themeId = getThemeIdValue();
const themeId = themeIdFlag ? themeIdFlag : getThemeIdValue();
const mainTheme = await _isMainTheme(themeId);
if (mainTheme.status === 'error') {
return {
Expand Down
7 changes: 4 additions & 3 deletions src/theme/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,19 @@ const createTheme = async (args) => {
spinner.succeed(
`Theme ${chalk.cyan(result.theme.name)} with id ${chalk.cyan(
result.theme.id
)} created and config.json updated!`
)} created and packer.config.json updated!`
);
console.log(table(parsed));
};

const removeTheme = async () => {
const removeTheme = async (args) => {
const themeIdFlag = args.id ? args.id : null;
clearConsole();
const spinner = ora(
chalk.magenta(`'Deleting theme for environment: ${getEnvNameValue()} ...'`)
);
spinner.start();
const result = await remove();
const result = await remove(themeIdFlag);
if (result.status === 'error') {
spinner.color = 'red';
spinner.fail(chalk.red(result.message));
Expand Down

0 comments on commit 12b1fde

Please sign in to comment.