chisel-scripts 1.0.0 → 2.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +0 -23
  3. package/bin/chisel-scripts.js +5 -23
  4. package/composer.phar +0 -0
  5. package/fetch-packages.js +30 -0
  6. package/index.js +60 -0
  7. package/lib/PluginAPI.js +4 -44
  8. package/lib/Service.js +25 -181
  9. package/lib/commands/add-page.js +92 -0
  10. package/lib/commands/composer.js +22 -0
  11. package/lib/commands/create-block/index.js +45 -0
  12. package/lib/commands/create-block/templates/README.md +5 -0
  13. package/lib/commands/create-block/templates/acf/block/edit.js.mustache +38 -0
  14. package/lib/commands/create-block/templates/acf/block/editor.scss.mustache +9 -0
  15. package/lib/commands/create-block/templates/acf/block/index.js.mustache +45 -0
  16. package/lib/commands/create-block/templates/acf/block/render.php.mustache +10 -0
  17. package/lib/commands/create-block/templates/acf/block/save.js.mustache +26 -0
  18. package/lib/commands/create-block/templates/acf/block/style.scss.mustache +12 -0
  19. package/lib/commands/create-block/templates/acf/block/view.js.mustache +25 -0
  20. package/lib/commands/create-block/templates/acf/index.js +3 -0
  21. package/lib/commands/wp-config.js +116 -0
  22. package/lib/commands/wp-scripts.mjs +70 -0
  23. package/lib/commands/wp.js +22 -0
  24. package/lib/extensions/stylesheets.mjs +51 -0
  25. package/lib/template/dev-vhost.chisel-tpl.conf +8 -0
  26. package/lib/template/wp-config-local.chisel-tpl.php +56 -0
  27. package/package.json +11 -37
  28. package/wp-cli.phar +0 -0
  29. package/lib/chisel.config.base.js +0 -31
  30. package/lib/commands/build/formatStats.js +0 -79
  31. package/lib/commands/build/index.js +0 -125
  32. package/lib/commands/inspect.js +0 -14
  33. package/lib/config/base.js +0 -201
  34. package/lib/config/css.js +0 -91
  35. package/lib/config/js.js +0 -52
  36. package/lib/generate-and-serialize-config.js +0 -9
  37. package/lib/webpack-loaders/sass-glob-loader.js +0 -41
  38. package/lib/webpack-plugins/DynamicPublicPath.js +0 -24
  39. package/lib/webpack-plugins/OptimizeCssnanoPlugin.js +0 -125
  40. package/webpack.config-sync.js +0 -16
  41. package/webpack.config.js +0 -9
@@ -1,125 +0,0 @@
1
- // Based on https://github.com/intervolga/optimize-cssnano-plugin/blob/123de8b2212dbe5335be1a5c49e981ec8c2e1268/index.js
2
- // changed regexp to work with unminified-webpack-plugin
3
- /* eslint-disable */
4
-
5
- const cssnano = require('cssnano');
6
- const postcss = require('postcss');
7
-
8
- /**
9
- * Optimize cssnano plugin
10
- *
11
- * @param {Object} options
12
- */
13
- function OptimizeCssnanoPlugin(options) {
14
- this.options = Object.assign({
15
- sourceMap: false,
16
- cssnanoOptions: {
17
- preset: 'default',
18
- },
19
- }, options);
20
-
21
- if (this.options.sourceMap) {
22
- this.options.sourceMap = Object.assign(
23
- {inline: false},
24
- this.options.sourceMap || {});
25
- }
26
- }
27
-
28
- OptimizeCssnanoPlugin.prototype.apply = function(compiler) {
29
- const self = this;
30
-
31
- compiler.hooks.emit.tapAsync('OptimizeCssnanoPlugin',
32
- function(compilation, callback) {
33
- // Search for CSS assets
34
- const assetsNames = Object.keys(compilation.assets)
35
- .filter((assetName) => {
36
- return /(?<!\.full)\.css$/i.test(assetName);
37
- });
38
-
39
- let hasErrors = false;
40
- const promises = [];
41
- // Generate promises for each minification
42
- assetsNames.forEach((assetName) => {
43
- // Original CSS
44
- const asset = compilation.assets[assetName];
45
- const originalCss = asset.source();
46
-
47
- // Options for particalar cssnano call
48
- const postCssOptions = {
49
- from: assetName,
50
- to: assetName,
51
- map: false,
52
- };
53
- const cssnanoOptions = self.options.cssnanoOptions;
54
-
55
- // Extract or remove previous map
56
- const mapName = assetName + '.map';
57
- if (self.options.sourceMap) {
58
- // Use previous map if exist...
59
- if (compilation.assets[mapName]) {
60
- const mapObject = JSON.parse(compilation.assets[mapName].source());
61
-
62
- // ... and not empty
63
- if (mapObject.sources.length > 0 || mapObject.mappings.length > 0) {
64
- postCssOptions.map = Object.assign({
65
- prev: compilation.assets[mapName].source(),
66
- }, self.options.sourceMap);
67
- } else {
68
- postCssOptions.map = Object.assign({}, self.options.sourceMap);
69
- }
70
- }
71
- } else {
72
- delete compilation.assets[mapName];
73
- }
74
-
75
- // Run minification
76
- const promise = postcss([cssnano(cssnanoOptions)])
77
- .process(originalCss, postCssOptions)
78
- .then((result) => {
79
- if (hasErrors) {
80
- return;
81
- }
82
-
83
- // Extract CSS back to assets
84
- const processedCss = result.css;
85
- compilation.assets[assetName] = {
86
- source: function() {
87
- return processedCss;
88
- },
89
- size: function() {
90
- return processedCss.length;
91
- },
92
- };
93
-
94
- // Extract map back to assets
95
- if (result.map) {
96
- const processedMap = result.map.toString();
97
-
98
- compilation.assets[mapName] = {
99
- source: function() {
100
- return processedMap;
101
- },
102
- size: function() {
103
- return processedMap.length;
104
- },
105
- };
106
- }
107
- }
108
- ).catch(function(err) {
109
- hasErrors = true;
110
- throw new Error('CSS minification error: ' + err.message +
111
- '. File: ' + assetName);
112
- }
113
- );
114
- promises.push(promise);
115
- });
116
-
117
- Promise.all(promises)
118
- .then(function() {
119
- callback();
120
- })
121
- .catch(callback);
122
- });
123
- };
124
-
125
- module.exports = OptimizeCssnanoPlugin;
@@ -1,16 +0,0 @@
1
- // eslint-plugin-import requires config to be returned synchronously
2
- // This is absolutely awful way to do that
3
-
4
- const { execa } = require('chisel-shared-utils');
5
-
6
- const { stdout, stderr } = execa.sync(process.execPath, [
7
- ...process.execArgv,
8
- require.resolve('./lib//generate-and-serialize-config.js'),
9
- ]);
10
-
11
- process.stderr.write(stderr);
12
-
13
- // eslint-disable-next-line no-eval
14
- const cfg = eval(`(${stdout})`);
15
-
16
- module.exports = cfg;
package/webpack.config.js DELETED
@@ -1,9 +0,0 @@
1
- const Service = require('./lib/Service');
2
-
3
- const service = new Service();
4
-
5
- module.exports = (async () => {
6
- await service.init();
7
-
8
- return service.resolveWebpackConfig();
9
- })();