Skip to content

Commit 23b598d

Browse files
committed
Prebuild /lib
1 parent 7f0833f commit 23b598d

23 files changed

+1586
-1
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ bower_components
4848
.DS_Store
4949
bundle.js
5050
test/output
51-
lib/
51+
# lib/

lib/commands/build.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
exports.default = function (program) {
8+
program.command('build').alias('b').description('Compiles source files (<theme>/src/) into the format required for distribution to a Shopify store (<theme>/dist/).').action(function () {
9+
logger('--gulpfile ' + _config2.default.gulpFile);
10+
logger('--cwd ' + _config2.default.themeRoot);
11+
12+
(0, _crossSpawn2.default)(_config2.default.gulp, ['build', '--gulpfile', _config2.default.gulpFile, '--cwd', _config2.default.themeRoot], {
13+
detached: false,
14+
stdio: 'inherit'
15+
});
16+
});
17+
};
18+
19+
var _crossSpawn = require('cross-spawn');
20+
21+
var _crossSpawn2 = _interopRequireDefault(_crossSpawn);
22+
23+
var _debug = require('debug');
24+
25+
var _debug2 = _interopRequireDefault(_debug);
26+
27+
var _config = require('../config');
28+
29+
var _config2 = _interopRequireDefault(_config);
30+
31+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
32+
33+
var logger = (0, _debug2.default)('slate-tools:build');

lib/commands/deploy.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
exports.default = function (program) {
8+
program.command('deploy').alias('d').description('Runs a full deploy of your theme\'s code to a Shopify store specified in config.yml. Existing files will be overwritten.').option('-e, --env <environment>[,<environment>...]', 'Shopify store(s) to deploy code to (specified in config.yml - default: development)', 'development').option('-m, --manual', 'outputs the compiled theme files to <theme>/upload/<theme>.zip for manual deployment').action(function () {
9+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
10+
11+
logger('--gulpfile ' + _config2.default.gulpFile);
12+
logger('--cwd ' + _config2.default.themeRoot);
13+
14+
var args = options.manual ? ['deploy:manual'] : ['deploy', '--environment', options.env];
15+
16+
(0, _crossSpawn2.default)(_config2.default.gulp, args.concat(['--gulpfile', _config2.default.gulpFile, '--cwd', _config2.default.themeRoot]), {
17+
detached: false,
18+
stdio: 'inherit'
19+
});
20+
});
21+
};
22+
23+
var _crossSpawn = require('cross-spawn');
24+
25+
var _crossSpawn2 = _interopRequireDefault(_crossSpawn);
26+
27+
var _debug = require('debug');
28+
29+
var _debug2 = _interopRequireDefault(_debug);
30+
31+
var _config = require('../config');
32+
33+
var _config2 = _interopRequireDefault(_config);
34+
35+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36+
37+
var logger = (0, _debug2.default)('slate-tools:deploy');

lib/commands/start.js

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
exports.default = function (program) {
8+
program.command('start').alias('s').description('Runs a clean build & deploy of the theme\'s source files to a Shopify store specified in config.yml, ' + 'then starts file watch and live-reload tasks, allowing for immediate updates during development.').option('-e, --env <environment>[,<environment>...]', 'Shopify store(s) to deploy code to (specified in config.yml - default: development)', 'development').option('-n, --nosync', 'disable live-reload functionality').action(function () {
9+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
10+
11+
logger('--gulpfile ' + _config2.default.gulpFile);
12+
logger('--cwd ' + _config2.default.themeRoot);
13+
14+
var args = ['--gulpfile', _config2.default.gulpFile, '--cwd', _config2.default.themeRoot, '--environment', options.env];
15+
16+
if (options.nosync) {
17+
args.push('--nosync');
18+
}
19+
20+
(0, _crossSpawn2.default)(_config2.default.gulp, args, {
21+
detached: false,
22+
stdio: 'inherit'
23+
});
24+
});
25+
};
26+
27+
var _crossSpawn = require('cross-spawn');
28+
29+
var _crossSpawn2 = _interopRequireDefault(_crossSpawn);
30+
31+
var _debug = require('debug');
32+
33+
var _debug2 = _interopRequireDefault(_debug);
34+
35+
var _config = require('../config');
36+
37+
var _config2 = _interopRequireDefault(_config);
38+
39+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40+
41+
var logger = (0, _debug2.default)('slate-tools:start');

lib/commands/test.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
exports.default = function (program) {
8+
program.command('test').description('Runs translation tests for a theme\'s locale files (<theme>/src/locales/).').action(function () {
9+
logger('--gulpfile ' + _config2.default.gulpFile);
10+
logger('--cwd ' + _config2.default.themeRoot);
11+
12+
(0, _crossSpawn2.default)(_config2.default.gulp, ['test', '--gulpfile', _config2.default.gulpFile, '--cwd', _config2.default.themeRoot], {
13+
detached: false,
14+
stdio: 'inherit'
15+
});
16+
});
17+
};
18+
19+
var _crossSpawn = require('cross-spawn');
20+
21+
var _crossSpawn2 = _interopRequireDefault(_crossSpawn);
22+
23+
var _debug = require('debug');
24+
25+
var _debug2 = _interopRequireDefault(_debug);
26+
27+
var _config = require('../config');
28+
29+
var _config2 = _interopRequireDefault(_config);
30+
31+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
32+
33+
var logger = (0, _debug2.default)('slate-tools:test');

lib/commands/watch.js

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
exports.default = function (program) {
8+
program.command('watch').alias('w').description('Watches files for code changes and immediately deploys updates to your store as they occur. ' + 'By default, this command also runs a live-reload proxy that refreshes your store URL in-browser when changes are successfully deployed.').option('-e, --env <environment>', 'Shopify store to deploy code to (specified in config.yml - default: development)', 'development').option('-n, --nosync', 'disable live-reload functionality').action(function () {
9+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
10+
11+
logger('--gulpfile ' + _config2.default.gulpFile);
12+
logger('--cwd ' + _config2.default.themeRoot);
13+
14+
var args = ['watch', '--gulpfile', _config2.default.gulpFile, '--cwd', _config2.default.themeRoot, '--environment', options.env];
15+
16+
if (options.nosync) {
17+
args.push('--nosync');
18+
}
19+
20+
(0, _crossSpawn2.default)(_config2.default.gulp, args, {
21+
detached: false,
22+
stdio: 'inherit'
23+
});
24+
});
25+
};
26+
27+
var _crossSpawn = require('cross-spawn');
28+
29+
var _crossSpawn2 = _interopRequireDefault(_crossSpawn);
30+
31+
var _debug = require('debug');
32+
33+
var _debug2 = _interopRequireDefault(_debug);
34+
35+
var _config = require('../config');
36+
37+
var _config2 = _interopRequireDefault(_config);
38+
39+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40+
41+
var logger = (0, _debug2.default)('slate-tools:watch');

lib/commands/zip.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
exports.default = function (program) {
8+
program.command('zip').alias('z').description('Rebuilds the theme\'s source files and compresses the output. The compressed file is written to <theme>/upload/<theme>.zip (can be used for manual upload).').action(function () {
9+
logger('--gulpfile ' + _config2.default.gulpFile);
10+
logger('--cwd ' + _config2.default.themeRoot);
11+
12+
(0, _crossSpawn2.default)(_config2.default.gulp, ['zip', '--gulpfile', _config2.default.gulpFile, '--cwd', _config2.default.themeRoot], {
13+
detached: false,
14+
stdio: 'inherit'
15+
});
16+
});
17+
};
18+
19+
var _crossSpawn = require('cross-spawn');
20+
21+
var _crossSpawn2 = _interopRequireDefault(_crossSpawn);
22+
23+
var _debug = require('debug');
24+
25+
var _debug2 = _interopRequireDefault(_debug);
26+
27+
var _config = require('../config');
28+
29+
var _config2 = _interopRequireDefault(_config);
30+
31+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
32+
33+
var logger = (0, _debug2.default)('slate-tools:zip');

lib/config.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
var _path = require('path');
8+
9+
var _fs = require('fs');
10+
11+
var _findRoot = require('find-root');
12+
13+
var _findRoot2 = _interopRequireDefault(_findRoot);
14+
15+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16+
17+
var workingDirectory = process.cwd();
18+
var currentDirectory = __dirname;
19+
20+
var themeRoot = (0, _findRoot2.default)(workingDirectory);
21+
var defaultGulpPath = (0, _path.join)(themeRoot, (0, _path.normalize)('node_modules/.bin/gulp'));
22+
// Legacy path for older versions of Node.
23+
var legacyGulpPath = (0, _path.join)(themeRoot, (0, _path.normalize)('node_modules/@shopify/slate-tools/node_modules/.bin/gulp'));
24+
25+
var config = {
26+
gulpFile: (0, _path.join)(currentDirectory, 'gulpfile.js'),
27+
gulp: (0, _fs.existsSync)(defaultGulpPath) ? defaultGulpPath : legacyGulpPath,
28+
themeRoot: themeRoot
29+
};
30+
31+
exports.default = config;

0 commit comments

Comments
 (0)