Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
NickTolhurst26 authored Sep 24, 2020
2 parents c5d964b + af6204b commit 0faf9de
Show file tree
Hide file tree
Showing 47 changed files with 1,740 additions and 1,578 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v10.16.3
v12.18.4
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ addons:
ssh_known_hosts:
- github.com
node_js:
- 10
- 10.22.1
- 12.18.4

cache:
directories:
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
The BigCommerce server emulator for local theme development.

## Install
_Note: Stencil requires the Node.js runtime environment, version 10.x We do not yet have support for Node 12 or greater._
_Note: Stencil requires the Node.js runtime environment,
version 10.x and 12.x (Recommended) are supported.
We do not yet have support for versions greater than Node 12._

Run `npm install -g @bigcommerce/stencil-cli`.

Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
environment:
matrix:
- nodejs_version: "10"
- nodejs_version: "12"
platform:
- x86
- x64
Expand Down
38 changes: 15 additions & 23 deletions bin/stencil-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,32 @@

require('colors');

var Program = require('commander');
var ThemeConfig = require('../lib/theme-config');
var pkg = require('../package.json');
var themePath = process.cwd();
var configuration;
var bundle;
var Bundle = require('../lib/stencil-bundle');
var themeConfig;
var versionCheck = require('../lib/version-check');

Program
.version(pkg.version)
const program = require('../lib/commander');
const { THEME_PATH, PACKAGE_INFO } = require('../constants');
const ThemeConfig = require('../lib/theme-config');
const Bundle = require('../lib/stencil-bundle');
const versionCheck = require('../lib/version-check');

program
.version(PACKAGE_INFO.version)
.option('-d, --dest [dest]', 'Where to save the zip file. It defaults to the current directory you are in when bundling')
.option('-n, --name [filename]', 'What do you want to call the zip file. It defaults to stencil-bundle.zip')
.option('-m, --marketplace', 'Runs extra bundle validations for partners who can create marketplace themes')
.parse(process.argv);

const cliOptions = program.opts();
const themeConfig = ThemeConfig.getInstance(THEME_PATH);

if (!versionCheck()) {
process.exit(2);
}

themeConfig = ThemeConfig.getInstance(themePath);

if (Program.dest === true) {
if (cliOptions.dest === true) {
console.error('Error: You have to specify a value for -d or --dest'.red);
process.exit(2);
}

if (Program.name === true) {
if (cliOptions.name === true) {
console.error('Error: You have to specify a value for -n or --name'.red);
process.exit(2);
}
Expand All @@ -40,13 +37,8 @@ if (!themeConfig.configExists()) {
process.exit(2);
}

configuration = themeConfig.getRawConfig();

bundle = new Bundle(themePath, themeConfig, configuration, {
marketplace: Program.marketplace,
dest: Program.dest,
name: Program.name,
});
const rawConfig = themeConfig.getRawConfig();
const bundle = new Bundle(THEME_PATH, themeConfig, rawConfig, cliOptions);

bundle.initBundle((err, bundlePath) => {
if (err) {
Expand Down
30 changes: 13 additions & 17 deletions bin/stencil-download.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@

require('colors');
const inquirer = require('inquirer');
const Program = require('commander');
const { promisify } = require("util");
const program = require('../lib/commander');

const pkg = require('../package.json');
const { API_HOST, PACKAGE_INFO, DOT_STENCIL_FILE_PATH } = require('../constants');
const stencilDownload = require('../lib/stencil-download');
const versionCheck = require('../lib/version-check');
const themeApiClient = require('../lib/theme-api-client');
const { printCliResultError } = require('../lib/cliCommon');

const apiHost = 'https://api.bigcommerce.com';

Program
.version(pkg.version)
.option('--host [hostname]', 'specify the api host', apiHost)
program
.version(PACKAGE_INFO.version)
.option('--host [hostname]', 'specify the api host', API_HOST)
.option('--file [filename]', 'specify the filename to download only')
.option('--exclude [exclude]', 'specify a directory to exclude from download')
.parse(process.argv);
Expand All @@ -23,12 +20,13 @@ if (!versionCheck()) {
process.exit(2);
}

const extraExclude = Program.exclude ? [Program.exclude] : [];
const cliOptions = program.opts();
const extraExclude = cliOptions.exclude ? [cliOptions.exclude] : [];
const options = {
dotStencilFilePath: './.stencil',
dotStencilFilePath: DOT_STENCIL_FILE_PATH,
exclude: ['parsed', 'manifest.json', ...extraExclude],
apiHost: Program.host || apiHost,
file: Program.file,
apiHost: cliOptions.host || API_HOST,
file: cliOptions.file,
};

run(options);
Expand All @@ -51,11 +49,9 @@ async function run (opts) {
console.log(`${'ok'.green} -- ${overwriteType} will be overwritten by change`);

try {
await promisify(stencilDownload)(opts);
await stencilDownload(opts);
} catch (err) {
console.log("\n\n" + 'not ok'.red + ` -- ${err} see details below:`);
themeApiClient.printErrorMessages(err.messages);
console.log('If this error persists, please visit https://github.com/bigcommerce/stencil-cli/issues and submit an issue.');
printCliResultError(err);
return;
}

Expand Down
15 changes: 6 additions & 9 deletions bin/stencil-init.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#!/usr/bin/env node

require('colors');
const Program = require('commander');
const _ = require('lodash');
const program = require('../lib/commander');

const StencilInit = require('../lib/stencil-init');
const pkg = require('../package.json');
const { DOT_STENCIL_FILE_PATH, PACKAGE_INFO } = require('../constants');
const versionCheck = require('../lib/version-check');

Program
.version(pkg.version)
program
.version(PACKAGE_INFO.version)
.option('-u, --url [url]', 'Store URL')
.option('-t, --token [token]', 'Access Token')
.option('-p, --port [port]', 'Port')
Expand All @@ -19,10 +17,9 @@ if (!versionCheck()) {
process.exit(2);
}

const dotStencilFilePath = './.stencil';
const cliOptions = _.pick(Program, ['url', 'token', 'port']);
const cliOptions = program.opts();

new StencilInit().run(dotStencilFilePath,
new StencilInit().run(DOT_STENCIL_FILE_PATH,
{
normalStoreUrl: cliOptions.url,
accessToken: cliOptions.token,
Expand Down
36 changes: 18 additions & 18 deletions bin/stencil-pull.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
#!/usr/bin/env node

require('colors');
const apiHost = 'https://api.bigcommerce.com';
const dotStencilFilePath = './.stencil';
const options = { dotStencilFilePath };
const pkg = require('../package.json');
const Program = require('commander');

const { DOT_STENCIL_FILE_PATH, PACKAGE_INFO, API_HOST } = require('../constants');
const program = require('../lib/commander');
const stencilPull = require('../lib/stencil-pull');
const versionCheck = require('../lib/version-check');
const themeApiClient = require('../lib/theme-api-client');
const { printCliResultError} = require('../lib/cliCommon');

Program
.version(pkg.version)
.option('--host [hostname]', 'specify the api host', apiHost)
program
.version(PACKAGE_INFO.version)
.option('--host [hostname]', 'specify the api host', API_HOST)
.option('--save [filename]', 'specify the filename to save the config as', 'config.json')
.parse(process.argv);

if (!versionCheck()) {
process.exit(2);
}

stencilPull(Object.assign({}, options, {
apiHost: Program.host || apiHost,
saveConfigName: Program.save,
}), (err, result) => {
const cliOptions = program.opts();
const options = {
dotStencilFilePath: DOT_STENCIL_FILE_PATH,
apiHost: cliOptions.host || API_HOST,
saveConfigName: cliOptions.save,
};

stencilPull(options, (err, result) => {
if (err) {
console.log("\n\n" + 'not ok'.red + ` -- ${err} see details below:`);
themeApiClient.printErrorMessages(err.messages);
console.log('If this error persists, please visit https://github.com/bigcommerce/stencil-cli/issues and submit an issue.');
} else {
console.log('ok'.green + ` -- Pulled active theme config to ${result.saveConfigName}`);
printCliResultError(err);
return;
}
console.log('ok'.green + ` -- Pulled active theme config to ${result.saveConfigName}`);
});
40 changes: 19 additions & 21 deletions bin/stencil-push.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
#!/usr/bin/env node

require('colors');
const apiHost = 'https://api.bigcommerce.com';
const dotStencilFilePath = './.stencil';
const options = { dotStencilFilePath };
const pkg = require('../package.json');
const Program = require('commander');
const { DOT_STENCIL_FILE_PATH, PACKAGE_INFO, API_HOST } = require('../constants');
const program = require('../lib/commander');
const stencilPush = require('../lib/stencil-push');
const versionCheck = require('../lib/version-check');
const themeApiClient = require('../lib/theme-api-client');
const { printCliResultError } = require('../lib/cliCommon');

Program
.version(pkg.version)
.option('--host [hostname]', 'specify the api host', apiHost)
program
.version(PACKAGE_INFO.version)
.option('--host [hostname]', 'specify the api host', API_HOST)
.option('-f, --file [filename]', 'specify the filename of the bundle to upload')
.option('-s, --save [filename]', 'specify the filename to save the bundle as')
.option('-a, --activate [variationname]', 'specify the variation of the theme to activate')
Expand All @@ -23,18 +20,19 @@ if (!versionCheck()) {
process.exit(2);
}

stencilPush(Object.assign({}, options, {
apiHost: Program.host || apiHost,
bundleZipPath: Program.file,
activate: Program.activate,
saveBundleName: Program.save,
deleteOldest: Program.delete,
}), (err, result) => {
const cliOptions = program.opts();
const options = {
dotStencilFilePath: DOT_STENCIL_FILE_PATH,
apiHost: cliOptions.host || API_HOST,
bundleZipPath: cliOptions.file,
activate: cliOptions.activate,
saveBundleName: cliOptions.save,
deleteOldest: cliOptions.delete,
};
stencilPush(options, (err, result) => {
if (err) {
console.log("\n\n" + 'not ok'.red + ` -- ${err} see details below:`);
themeApiClient.printErrorMessages(err.messages);
console.log('If this error persists, please visit https://github.com/bigcommerce/stencil-cli/issues and submit an issue.');
} else {
console.log('ok'.green + ` -- ${result}`);
printCliResultError(err);
return;
}
console.log('ok'.green + ` -- ${result}`);
});
8 changes: 4 additions & 4 deletions bin/stencil-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

require('colors');
const release = require('../lib/release/release');
const pkg = require('../package.json');
const Program = require('commander');
const { PACKAGE_INFO } = require('../constants');
const program = require('../lib/commander');
const versionCheck = require('../lib/version-check');

Program
.version(pkg.version)
program
.version(PACKAGE_INFO.version)
.parse(process.argv);

if (!versionCheck()) {
Expand Down
Loading

0 comments on commit 0faf9de

Please sign in to comment.