Skip to content
This repository was archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
Refactor themekit abstraction (#77)
Browse files Browse the repository at this point in the history
* refactor for node-themekit

* testing themekit module

* remove slate setup and update deps

* update to scoped themekit

* fix eslint version

* remove unused deps and unnecessary promises
  • Loading branch information
Ryan Macdonald authored and Thomas Kelly committed Jul 31, 2017
1 parent 737985a commit 027158f
Show file tree
Hide file tree
Showing 14 changed files with 530 additions and 685 deletions.
2 changes: 2 additions & 0 deletions packages/slate-cli/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ rules:
spaced-comment: 0
no-process-env: 0
indent: ["error", 2, {"SwitchCase": 1}]
globals:
Promise: 1
22 changes: 1 addition & 21 deletions packages/slate-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ Clone the latest version of Slate CLI to your local machine using SSH
git clone [email protected]:Shopify/slate-cli.git
```



#### 2. Run npm link
```shell
cd slate-cli
Expand All @@ -38,14 +36,6 @@ a symbolic link to your global npm directory.
You should now be able to run slate from your terminal. Try running `slate -v` to verify that everything worked
(if this didn't work, see [Troubleshooting](#troubleshooting) for guidance).

#### 3. Run slate setup

```shell
slate setup
```

This command installs [ThemeKit](http://themekit.cat) and other non-node dependencies. More details [here](#setup).

## Getting started

#### 1. Create a new project
Expand Down Expand Up @@ -101,8 +91,7 @@ You're ready to start developing with Slate. To get started, run the following

1. Pull the latest version from GitHub - Make sure that your current branch is master and that your master branch is up-to-date.
2. Run `npm update` - This will update all project dependencies and developer tools listed in the [package.json](package.json) file.
3. Run `slate setup` - This installs project-specific dependencies and developer tools. More details [here](#setup).
4. Run `npm prune` and `npm install` (optional) - After major changes, it may be necessary to clean out your `node_modules` and
3. Run `npm prune` and `npm install` (optional) - After major changes, it may be necessary to clean out your `node_modules` and
make sure that new modules have been correctly installed.

This will remove any unused dependencies from `node_modules` and install all new dependencies.
Expand All @@ -111,19 +100,11 @@ make sure that new modules have been correctly installed.

Command | Usage
--- | ---
[setup](#setup) | `slate setup`
[new theme](#new-theme) | `slate new theme [name]`
[new section](#new-section) | `slate new section [name]`
[help](#help) | `slate -h`
[version](#version) | `slate -v`

### setup
```
slate setup
```

Installs [Theme Kit](http://themekit.cat/), a cross-platform tool which provides utilities that allow you to interact with Shopify themes.

### new theme
```
slate new theme [name]
Expand Down Expand Up @@ -239,7 +220,6 @@ If you encounter any issues, here are some preliminary steps to take:

- `git pull` latest version of Slate CLI.
- `npm install` to make sure you have all the dependencies.
- `slate setup` to make sure all Slate CLI dependencies are installed.
- `npm link` to make sure that the symlink exists and Slate CLI is globally installed.

## License
Expand Down
7 changes: 3 additions & 4 deletions packages/slate-cli/bin/slate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ var parseOptions = require('nopt');
var slate = require('../index.js');
var msg = require('../includes/messages.js');

/* eslint-disable quote-props ,id-length */
/* eslint-disable quote-props, id-length */
var validOpts = {
'environment': String,
'help': Boolean,
'manual': Boolean, // flag for manual deploy (used with deploy command)
'manual': Boolean,
'nosync': Boolean,
'version': Boolean
};
Expand All @@ -24,6 +24,7 @@ var shorthand = {

// filtered list of valid options that were passed w/ the command
var opts = parseOptions(validOpts, shorthand);

if (opts.argv.remain[0]) {
var command = opts.argv.remain[0]; // the first arg in the `remain` array is the command
var args = opts.argv.remain.slice(1); // the remaining args to be passed with the command
Expand All @@ -38,8 +39,6 @@ if (opts.argv.remain[0]) {
process.stdout.write(msg.unknownCommand());
slate.help.command();
}

// No args were passed...
} else {
if (opts.version) {
slate.version.command();
Expand Down
1 change: 0 additions & 1 deletion packages/slate-cli/circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ dependencies:
test:
override:
- npm run lint
- slate setup
26 changes: 23 additions & 3 deletions packages/slate-cli/commands/remove.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
var msg = require('../includes/messages.js');
var themekit = require('../includes/themekit.js');
var command = require('@shopify/themekit').command;

module.exports = {
command: function(args, options) {
if (args.length === 0) {
return process.stdout.write(msg.noFiles());
} else {
if (options.environment) {
return themekit.commands(['remove', '-env', options.environment].concat(args));
return new Promise(function(resolve, reject) {
command({
args: ['remove', '-env', options.environment].concat(args)
}, function(err) {
if (err) {
reject(err);
} else {
resolve();
}
});
});
} else {
return themekit.commands(['remove'].concat(args));
return new Promise(function(resolve, reject) {
command({
args: ['remove'].concat(args)
}, function(err) {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}
}
}
Expand Down
26 changes: 23 additions & 3 deletions packages/slate-cli/commands/replace.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
var themekit = require('../includes/themekit.js');
var command = require('@shopify/themekit').command;

module.exports = {
command: function(args, options) {
if (options.environment) {
return themekit.commands(['replace', '-env', options.environment].concat(args));
return new Promise(function(resolve, reject) {
command({
args: ['replace', '-env', options.environment].concat(args)
}, function(err) {
if (err) {
reject(err);
} else {
resolve();
}
});
});
} else {
return themekit.commands(['replace'].concat(args));
return new Promise(function(resolve, reject) {
command({
args: ['replace'].concat(args)
}, function(err) {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}
}
};
37 changes: 0 additions & 37 deletions packages/slate-cli/commands/setup.js

This file was deleted.

26 changes: 23 additions & 3 deletions packages/slate-cli/commands/upload.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
var msg = require('../includes/messages.js');
var themekit = require('../includes/themekit.js');
var command = require('@shopify/themekit').command;

module.exports = {
command: function(args, options) {
if (args.length === 0) {
return process.stdout.write(msg.noFiles());
} else {
if (options.environment) {
return themekit.commands(['upload', '-env', options.environment].concat(args));
return new Promise(function(resolve, reject) {
command({
args: ['upload', '-env', options.environment].concat(args)
}, function(err) {
if (err) {
reject(err);
} else {
resolve();
}
});
});
} else {
return themekit.commands(['upload'].concat(args));
return new Promise(function(resolve, reject) {
command({
args: ['upload'].concat(args)
}, function(err) {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}
}
}
Expand Down
18 changes: 14 additions & 4 deletions packages/slate-cli/commands/version.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
var msg = require('../includes/messages.js');
var utils = require('../includes/utils.js');
var themekit = require('../includes/themekit.js');
var command = require('@shopify/themekit').command;

module.exports = {
command: function() {
return themekit.commands(['version'])
.then(function() {
process.stdout.write(msg.versionInfo());
return new Promise(function(resolve, reject) {
command({
args: ['version']
}, function(err) {
if (err) {
reject(err);
} else {
resolve();
}
});
})
.then(function() {
process.stdout.write(msg.versionInfo());
});
},
help: function() {
utils.logHelpMsg([
Expand Down
28 changes: 0 additions & 28 deletions packages/slate-cli/includes/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ module.exports = {
return 'Unknown command, please refer to help. \n';
},

fetchingDependencies: function() {
return 'Fetching dependencies...\n';
},

missingDependencies: function() {
return 'Dependencies missing. Please run slate setup\n';
},

noGenerator: function() {
return 'No generator specified, please use one of the following commands:\n' + this.generatorsList();
},
Expand All @@ -39,25 +31,5 @@ module.exports = {

scaffoldsList: function() {
return ' slate\n';
},

unknownInstaller: function() {
return 'Unknown installer, please use one of the following commands:\n' + this.installersList();
},

installersList: function() {
return ' slate setup themekit\n';
},

installerPath: function(name, path) {
return name + ': ' + path + '\n';
},

installerFailed: function(name, error) {
return name + ' failed to install\n ' + error + '\n';
},

installerSuccess: function(name) {
return name + ' successfully installed\n';
}
};
Loading

0 comments on commit 027158f

Please sign in to comment.