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

Commit

Permalink
Merge branch '1.x' into fix-ssl-cert-path
Browse files Browse the repository at this point in the history
  • Loading branch information
t-kelly authored Mar 27, 2018
2 parents 460ae4f + 0a4d3a1 commit e4e6f10
Show file tree
Hide file tree
Showing 20 changed files with 3,086 additions and 1,797 deletions.
21 changes: 6 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,23 @@
"lint:fix": "eslint ./ --fix && prettier-stylelint **/*.scss",
"lint:fix-js": "eslint ./ --fix",
"lint:fix-styles": "prettier-stylelint --write",
"bootstrap": "yarn && node_modules/.bin/lerna bootstrap",
"bootstrap": "npm install && node_modules/.bin/lerna bootstrap",
"publish": "node_modules/.bin/lerna publish",
"changelog": "node_modules/.bin/lerna-changelog",
"clean": "node_modules/.bin/lerna clean"
},
"devDependencies": {
"archiver": "1.1.0",
"aws-sdk": "2.6.12",
"babel-jest": "^22.0.4",
"babel-plugin-syntax-trailing-function-commas": "^6.22.0",
"babel-preset-shopify": "^16.2.0",
"eslint": "^4.10.0",
"eslint-config-prettier": "^2.7.0",
"eslint-plugin-jest": "^21.2.0",
"eslint-plugin-prettier": "^2.3.1",
"eslint-plugin-shopify": "^18.0.0",
"github": "^11.0.0",
"jest": "^21.0.0",
"eslint-plugin-shopify": "^19.0.1",
"jest": "^22.4.2",
"lerna": "^2.8.0",
"lerna-changelog": "^0.6.0",
"mime-types": "2.1.12",
"lerna-changelog": "^0.7.0",
"prettier": "^1.7.4",
"prettier-stylelint": "^0.4.2",
"promise": "^8.0.1",
"stylelint": "^8.1.1",
"stylelint-config-shopify": "^3.0.0-beta.4"
"stylelint": "^9.1.2",
"stylelint-config-shopify": "^5.0.0"
},
"prettier": {
"singleQuote": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/create-slate-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@shopify/slate-env": "^1.0.0-alpha.26",
"chalk": "^2.3.0",
"commander": "^2.12.2",
"execa": "^0.8.0",
"execa": "^0.9.0",
"fs-extra": "^5.0.0",
"hosted-git-info": "^2.5.0",
"semver": "^5.5.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/html-webpack-liquid-asset-tags-plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const path = require('path');
// eslint-disable-next-line no-empty-function
function AssetTagToShopifyLiquid() {}

AssetTagToShopifyLiquid.prototype.apply = compiler => {
compiler.plugin('compilation', compilation => {
AssetTagToShopifyLiquid.prototype.apply = (compiler) => {
compiler.hooks.compilation.tap('Assets Tag Plugin', (compilation) => {
// https://github.com/jantimon/html-webpack-plugin#events
compilation.plugin('html-webpack-plugin-alter-asset-tags', (data, cb) => {
function fixTag(tag) {
Expand All @@ -31,7 +31,7 @@ AssetTagToShopifyLiquid.prototype.apply = compiler => {
data.head = data.head.map(fixTag);
data.body = data.body.map(fixTag);

cb(null, data);
return data;
});
});
};
Expand Down
2 changes: 1 addition & 1 deletion packages/slate-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"dependencies": {
"@shopify/slate-error": "^1.0.0-alpha.26",
"@shopify/slate-rc": "^1.0.0-alpha.26",
"axios": "^0.17.1",
"axios": "^0.18.0",
"chalk": "^2.3.0",
"inquirer": "^5.0.1",
"react-dev-utils": "^5.0.0",
Expand Down
10 changes: 4 additions & 6 deletions packages/slate-sync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
"@shopify/slate-analytics": "^1.0.0-alpha.26",
"@shopify/slate-config": "^1.0.0-alpha.26",
"@shopify/slate-env": "^1.0.0-alpha.26",
"@shopify/themekit": "0.6.11",
"@shopify/themekit": "0.6.12",
"array-flatten": "^2.1.1",
"chalk": "1.1.3",
"chalk": "2.3.2",
"figures": "^2.0.0",
"inquirer": "^5.0.1",
"jest": "20.0.3",
"minimatch": "^3.0.4",
"react-dev-utils": "0.5.2",
"yargs": "^11.0.0"
"jest": "22.4.2",
"react-dev-utils": "0.5.2"
}
}
10 changes: 4 additions & 6 deletions packages/slate-tag-webpack-plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ function FileListPlugin(version) {
}

FileListPlugin.prototype.apply = function(compiler) {
compiler.plugin('emit', (compilation, callback) => {
const asset = compilation.assets[SETTINGS_SCHEMA_PATH];
const schema = JSON.parse(asset._value);
compiler.hooks.emit.tap('Slate Tag Plugin', (compilation, callback) => {
const asset = compilation.assets[SETTINGS_SCHEMA_PATH].source();
const schema = JSON.parse(asset);

if (Array.isArray(schema) && typeof schema[0] === 'object') {
schema[0]['slate-version'] = this.version;
schema[0].theme_packaged_with = `@shopify/slate-tools@${this.version}`;
}

const jsonString = JSON.stringify(schema);
Expand All @@ -23,8 +23,6 @@ FileListPlugin.prototype.apply = function(compiler) {
return jsonString.length;
},
};

callback();
});
};

Expand Down
85 changes: 21 additions & 64 deletions packages/slate-tools/cli/commands/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
const argv = require('minimist')(process.argv.slice(2));
const figures = require('figures');
const chalk = require('chalk');
const createHash = require('crypto').createHash;
const express = require('express');
const fs = require('fs');
const path = require('path');
Expand All @@ -27,6 +26,7 @@ const slateEnv = require('@shopify/slate-env');
const config = require('../../slate-tools.config');
const webpackConfig = require('../../tools/webpack/config/dev');
const setEnvironment = require('../../tools/webpack/set-slate-env');
const getChangedFiles = require('../../tools/webpack/get-changed-files');
const packageJson = require('../../package.json');

event('slate-tools:start:start', {version: packageJson.version, webpackConfig});
Expand Down Expand Up @@ -59,55 +59,6 @@ const previewUrl = `${shopifyUrl}?preview_theme_id=${slateEnv.getThemeIdValue()}
let isFirstCompilation = true;
let isFirstDeploy = true;

const assetsHash = {};

/**
* Return an array of changed files that have been written to the file system.
* Uses the same method as write-file-webpack-plugin to determine which files
* have changed.
* @see https://github.com/gajus/write-file-webpack-plugin/blob/master/src/index.js#L134-L145
*
* @param assets Object Assets obejct from webpack stats.compilation object
* @return Array
*/
function getFilesFromAssets(stats) {
const assets = stats.compilation.assets;
let files = [];

Object.keys(assets).forEach(key => {
if (key === 'static.js') {
return;
}

const asset = assets[key];

if (asset.emitted && fs.existsSync(asset.existsAt)) {
if (key === 'scripts.js') {
const assetHash = stats.compilation.chunks[0].hash;

if (!assetsHash[key] || assetsHash[key] !== assetHash) {
files = [...files, asset.existsAt.replace(config.paths.dist, '')];
assetsHash[key] = assetHash;
}
} else {
const source = asset.source();
const assetSource = Array.isArray(source) ? source.join('\n') : source;
const assetHash = createHash('sha256')
.update(assetSource)
.digest('hex');

// new file, or existing one that changed
if (!assetsHash[key] || assetsHash[key] !== assetHash) {
files = [...files, asset.existsAt.replace(config.paths.dist, '')];
assetsHash[key] = assetHash;
}
}
}
});

return files;
}

app.use((req, res, next) => {
res.set('Access-Control-Allow-Origin', '*');
next();
Expand All @@ -116,19 +67,19 @@ app.use((req, res, next) => {
app.use(
webpackDevMiddleware(compiler, {
quiet: true,
reload: false,
reload: true,
}),
);

const hotMiddleware = webpackHotMiddleware(compiler);
app.use(hotMiddleware);

compiler.plugin('compile', () => {
compiler.hooks.compile.tap('Slate Tools Start', () => {
clearConsole();
spinner = ora(chalk.magenta(' Compiling...')).start();
});

compiler.plugin('done', async stats => {
compiler.hooks.done.tap('Slate Tools Start', async (stats) => {
spinner.stop();
clearConsole();

Expand All @@ -144,7 +95,7 @@ compiler.plugin('done', async stats => {
});
console.log(chalk.red('Failed to compile.\n'));
console.log(config.paths.lib);
messages.errors.forEach(message => {
messages.errors.forEach((message) => {
console.log(`${message}\n`);
});
// If errors exist, only show errors.
Expand All @@ -158,7 +109,7 @@ compiler.plugin('done', async stats => {
version: packageJson.version,
});
console.log(chalk.yellow('Compiled with warnings.\n'));
messages.warnings.forEach(message => {
messages.warnings.forEach((message) => {
console.log(`${message}\n`);
});
}
Expand All @@ -174,18 +125,14 @@ compiler.plugin('done', async stats => {
}

// files we'll upload
const files = getFilesFromAssets(stats);

if (!files.length) {
return;
}
const files = getChangedFiles(stats);

// files.forEach(file => {
// console.log(`\t${file}`);
// });
// console.log('\n');

const liquidFiles = files.filter(file => path.extname(file) === '.liquid');
const liquidFiles = files.filter((file) => path.extname(file) === '.liquid');

if (isFirstCompilation && argv.skipFirstDeploy) {
isFirstCompilation = false;
Expand All @@ -202,14 +149,24 @@ compiler.plugin('done', async stats => {
);

console.log(chalk.magenta('\nWatching for changes...'));
} else {
}

if (!liquidFiles.length) {
console.log(chalk.magenta('\nWatching for changes...'));

return hotMiddleware.publish({
action: 'shopify_upload_finished',
});
}

if (!argv.skipFirstDeploy && (!isFirstCompilation && argv.skipFirstDeploy)) {
if (isFirstDeploy) {
isFirstDeploy = false;
}

event('slate-tools:start:sync-start', {version: packageJson.version});

sync(files)
sync(liquidFiles)
.then(() => {
event('slate-tools:start:sync-end', {version: packageJson.version});

Expand All @@ -235,7 +192,7 @@ compiler.plugin('done', async stats => {
force: liquidFiles.length > 0,
});
})
.catch(error => {
.catch((error) => {
event('slate-tools:start:sync-error', {
error,
version: packageJson.version,
Expand Down
55 changes: 28 additions & 27 deletions packages/slate-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "@shopify/slate-tools",
"version": "1.0.0-alpha.26",
"description": "A modern development toolkit for Shopify themes",
"repository": "https://github.com/Shopify/slate/tree/1.x/packages/slate-tools",
"repository":
"https://github.com/Shopify/slate/tree/1.x/packages/slate-tools",
"license": "MIT",
"author": "Shopify",
"bugs": {
Expand All @@ -24,54 +25,54 @@
"@shopify/slate-sync": "^1.0.0-alpha.26",
"@shopify/slate-tag-webpack-plugin": "^1.0.0-alpha.26",
"@shopify/theme-lint": "^2.0.0",
"@shopify/themekit": "0.6.11",
"@shopify/themekit": "0.6.12",
"archiver": "^2.1.0",
"autoprefixer": "6.7.7",
"babel-cli": "6.24.1",
"babel-cli": "6.26.0",
"babel-jest": "20.0.3",
"babel-loader": "7.0.0",
"chalk": "1.1.3",
"clean-webpack-plugin": "0.1.16",
"babel-loader": "7.1.4",
"chalk": "2.3.2",
"clean-webpack-plugin": "0.1.19",
"console-control-strings": "^1.1.0",
"copy-webpack-plugin": "^4.2.3",
"cross-spawn": "5.1.0",
"css-loader": "0.28.1",
"css-loader": "0.28.10",
"cssnano": "3.10.0",
"escape-string-regexp": "1.0.5",
"eslint": "^4.12.0",
"eslint-loader": "1.7.1",
"eslint-plugin-import": "2.2.0",
"express": "4.15.3",
"extract-loader": "0.1.0",
"extract-text-webpack-plugin": "2.1.0",
"eslint-loader": "2.0.0",
"eslint-plugin-import": "2.9.0",
"express": "4.16.3",
"extract-loader": "^2.0.1",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"figures": "^2.0.0",
"file-loader": "0.11.1",
"file-loader": "1.1.11",
"fs-extra": "3.0.1",
"html-loader": "^0.5.5",
"html-webpack-include-assets-plugin": "^1.0.2",
"html-webpack-plugin": "2.28.0",
"img-loader": "2.0.0",
"html-webpack-plugin": "^3.0.6",
"img-loader": "2.0.1",
"inquirer": "^5.0.1",
"jest": "20.0.3",
"jest": "22.4.2",
"minimist": "1.2.0",
"node-sass": "^4.7.2",
"ora": "^1.3.0",
"postcss-loader": "2.0.5",
"ora": "^2.0.0",
"postcss-loader": "2.1.1",
"postcss-reporter": "^5.0.0",
"prettier": "^1.10.2",
"raw-loader": "^0.5.1",
"react-dev-utils": "0.5.2",
"sass-loader": "6.0.5",
"style-loader": "0.17.0",
"stylelint": "^8.2.0",
"sass-loader": "6.0.7",
"style-loader": "0.20.3",
"stylelint": "^9.1.2",
"stylelint-webpack-plugin": "^0.10.1",
"uglifyjs-webpack-plugin": "^1.0.1",
"uuid": "^3.2.1",
"webpack": "^3.8.1",
"webpack": "^4.1.1",
"webpack-dev-middleware": "1.10.2",
"webpack-hot-middleware": "2.18.0",
"webpack-merge": "4.1.0",
"write-file-webpack-plugin": "4.0.2",
"yamljs": "0.2.10",
"yargs": "^11.0.0"
"webpack-hot-middleware": "2.21.2",
"webpack-merge": "4.1.2",
"write-file-webpack-plugin": "4.2.0",
"yamljs": "0.2.10"
}
}
Loading

0 comments on commit e4e6f10

Please sign in to comment.