diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 0c73d790e6871..ce120ddf0aad5 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -38,6 +38,7 @@ /packages/babel-plugin-makepot @ntwb @nerrad @ajitbohra /packages/babel-preset-default @youknowriad @gziolo @ntwb @nerrad @ajitbohra /packages/browserslist-config @gziolo @ntwb @nerrad @ajitbohra +/packages/create-block @gziolo /packages/custom-templated-path-webpack-plugin @ntwb @nerrad @ajitbohra /packages/docgen @nosolosw /packages/e2e-test-utils @gziolo @ntwb @nerrad @ajitbohra diff --git a/package-lock.json b/package-lock.json index 9e47750359a4e..bc47297b0e90d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9553,15 +9553,6 @@ "integrity": "sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==", "dev": true }, - "@types/execa": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/@types/execa/-/execa-0.9.0.tgz", - "integrity": "sha512-mgfd93RhzjYBUHHV532turHC2j4l/qxsF/PbfDmprHDEUHmNZGlDn1CEsulGK3AfsPdhkWzZQT/S/k0UGhLGsA==", - "dev": true, - "requires": { - "@types/node": "*" - } - }, "@types/glob": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.1.tgz", @@ -10257,9 +10248,9 @@ "commander": "^4.1.0", "execa": "^4.0.0", "inquirer": "^7.0.3", + "lodash": "^4.17.15", "make-dir": "^3.0.0", "mustache": "^4.0.0", - "pkg-install": "^1.0.0", "write-pkg": "^4.0.0" } }, @@ -19473,261 +19464,17 @@ "node-pre-gyp": "^0.12.0" }, "dependencies": { - "abbrev": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", - "dev": true, - "optional": true - }, - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true, - "optional": true - }, - "aproba": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", - "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", - "dev": true, - "optional": true - }, - "are-we-there-yet": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", - "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", - "dev": true, - "optional": true, - "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" - } - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true, - "optional": true - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "optional": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, "chownr": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", - "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==", - "dev": true, - "optional": true - }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true, - "optional": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true, - "optional": true - }, - "console-control-strings": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true, - "optional": true - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true, - "optional": true - }, - "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "dev": true, - "optional": true, - "requires": { - "ms": "^2.1.1" - } - }, - "deep-extend": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", - "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", - "dev": true, - "optional": true - }, - "delegates": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", - "dev": true, - "optional": true - }, - "detect-libc": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", - "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", - "dev": true, - "optional": true - }, - "fs-minipass": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.5.tgz", - "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", - "dev": true, - "optional": true, - "requires": { - "minipass": "^2.2.1" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true, - "optional": true - }, - "gauge": { - "version": "2.7.4", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", - "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", - "dev": true, - "optional": true, - "requires": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - } - }, - "glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", - "dev": true, - "optional": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "has-unicode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", - "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", - "dev": true, - "optional": true - }, - "iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "dev": true, - "optional": true, - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "ignore-walk": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.1.tgz", - "integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==", - "dev": true, - "optional": true, - "requires": { - "minimatch": "^3.0.4" - } - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "optional": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true, - "optional": true - }, - "ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", - "dev": true, - "optional": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true, - "optional": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true, - "optional": true - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "optional": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.3.tgz", + "integrity": "sha512-i70fVHhmV3DtTl6nqvZOnIjbY0Pe4kAUjwHj8z0zAdgBtYrJyYwLKCCuRBQ5ppkyL0AkN7HKRnETdmdp1zqNXw==", "dev": true, "optional": true }, "minipass": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", - "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz", + "integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==", "dev": true, "optional": true, "requires": { @@ -19735,52 +19482,6 @@ "yallist": "^3.0.0" } }, - "minizlib": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", - "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", - "dev": true, - "optional": true, - "requires": { - "minipass": "^2.2.1" - } - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, - "optional": true, - "requires": { - "minimist": "0.0.8" - } - }, - "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", - "dev": true, - "optional": true - }, - "nan": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", - "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", - "dev": true, - "optional": true - }, - "needle": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/needle/-/needle-2.3.0.tgz", - "integrity": "sha512-QBZu7aAFR0522EyaXZM0FZ9GLpq6lvQ3uq8gteiDUp7wKdy0lSd2hPlgFwVuW1CBkfEs9PfDQsQzZghLs/psdg==", - "dev": true, - "optional": true, - "requires": { - "debug": "^4.1.0", - "iconv-lite": "^0.4.4", - "sax": "^1.2.4" - } - }, "node-pre-gyp": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.12.0.tgz", @@ -19811,273 +19512,33 @@ "osenv": "^0.1.4" } }, - "npm-bundled": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.6.tgz", - "integrity": "sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g==", - "dev": true, - "optional": true - }, - "npm-packlist": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.1.tgz", - "integrity": "sha512-+TcdO7HJJ8peiiYhvPxsEDhF3PJFGUGRcFsGve3vxvxdcpO2Z4Z7rkosRM0kWj6LfbK/P0gu3dzk5RU1ffvFcw==", - "dev": true, - "optional": true, - "requires": { - "ignore-walk": "^3.0.1", - "npm-bundled": "^1.0.1" - } - }, - "npmlog": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", - "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", - "dev": true, - "optional": true, - "requires": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true, - "optional": true - }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true, - "optional": true - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "optional": true, - "requires": { - "wrappy": "1" - } - }, - "os-homedir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", - "dev": true, - "optional": true - }, - "os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "dev": true, - "optional": true - }, - "osenv": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", - "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", - "dev": true, - "optional": true, - "requires": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.0" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true, - "optional": true - }, - "process-nextick-args": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", - "dev": true, - "optional": true - }, - "rc": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", - "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", - "dev": true, - "optional": true, - "requires": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true, - "optional": true - } - } - }, - "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "dev": true, - "optional": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", - "dev": true, - "optional": true, - "requires": { - "glob": "^7.1.3" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true, - "optional": true - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true, - "optional": true - }, - "sax": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", - "dev": true, - "optional": true - }, "semver": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", - "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", - "dev": true, - "optional": true - }, - "set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", - "dev": true, - "optional": true - }, - "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", - "dev": true, - "optional": true - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "dev": true, - "optional": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "optional": true, - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "optional": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", "dev": true, "optional": true }, "tar": { - "version": "4.4.8", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.8.tgz", - "integrity": "sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ==", + "version": "4.4.13", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.13.tgz", + "integrity": "sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA==", "dev": true, "optional": true, "requires": { "chownr": "^1.1.1", "fs-minipass": "^1.2.5", - "minipass": "^2.3.4", - "minizlib": "^1.1.1", + "minipass": "^2.8.6", + "minizlib": "^1.2.1", "mkdirp": "^0.5.0", "safe-buffer": "^5.1.2", - "yallist": "^3.0.2" - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true, - "optional": true - }, - "wide-align": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", - "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", - "dev": true, - "optional": true, - "requires": { - "string-width": "^1.0.2 || 2" + "yallist": "^3.0.3" } }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true, - "optional": true - }, "yallist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", "dev": true, "optional": true } @@ -29156,6 +28617,13 @@ "thenify-all": "^1.0.0" } }, + "nan": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", + "dev": true, + "optional": true + }, "nanomatch": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", @@ -31074,78 +30542,6 @@ "find-up": "^2.1.0" } }, - "pkg-install": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/pkg-install/-/pkg-install-1.0.0.tgz", - "integrity": "sha512-UGI8bfhrDb1KN01RZ7Bq08GRQc8rmVjxQ2up0g4mUHPCYDTK1FzQ0PMmLOBCHg3yaIijZ2U3Fn9ofLa4N392Ug==", - "dev": true, - "requires": { - "@types/execa": "^0.9.0", - "@types/node": "^11.9.4", - "execa": "^1.0.0" - }, - "dependencies": { - "@types/node": { - "version": "11.15.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-11.15.4.tgz", - "integrity": "sha512-z7deEbNOPcS7pb7uyaZhbITh18ruGghYh86VmUL2zJPKeu9tEAqF0goQH0dhWamHoBJpkyWroNxPZjzNvbYVCw==", - "dev": true - }, - "cross-spawn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", - "dev": true, - "requires": { - "nice-try": "^1.0.4", - "path-key": "^2.0.1", - "semver": "^5.5.0", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - } - }, - "execa": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", - "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", - "dev": true, - "requires": { - "cross-spawn": "^6.0.0", - "get-stream": "^4.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" - } - }, - "get-stream": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", - "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", - "dev": true, - "requires": { - "pump": "^3.0.0" - } - }, - "pump": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", - "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", - "dev": true, - "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - }, - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - } - } - }, "pkg-up": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-2.0.0.tgz", diff --git a/packages/create-block/CHANGELOG.md b/packages/create-block/CHANGELOG.md index 6c62bcddeeb7b..872fdec9f6fde 100644 --- a/packages/create-block/CHANGELOG.md +++ b/packages/create-block/CHANGELOG.md @@ -1,5 +1,14 @@ ## Master +### Enhancements + +- Removed the code that clears the terminal while the block is scaffolded ([#19867](https://github.com/WordPress/gutenberg/pull/19867)). + +### Bug Fixes + +- Use the description provided to fill the `description` field in `package.json` file in ESNext template ([#19867](https://github.com/WordPress/gutenberg/pull/19867)). +- Ensure that values provided for slug and namespace get converted to lower case ([#19867](https://github.com/WordPress/gutenberg/pull/19867)). + ### Internal -- Imported from `create-wordpress-block` npm packgage. +- Imported from `create-wordpress-block` npm packgage ([#19773](https://github.com/WordPress/gutenberg/pull/19773)). diff --git a/packages/create-block/README.md b/packages/create-block/README.md index 9e93da468c1e3..7caf083213b84 100644 --- a/packages/create-block/README.md +++ b/packages/create-block/README.md @@ -53,6 +53,8 @@ Options: -h, --help output usage information ``` +_Please note that `--version` and `--help` options don't work with `npm init`. You have to use `npx` instead, as presented in the examples._ + More examples: 1. Interactive mode - it gives a chance to customize a few most important options diff --git a/packages/create-block/lib/index.js b/packages/create-block/lib/index.js index 51c8d56755f3e..f594e655fec03 100644 --- a/packages/create-block/lib/index.js +++ b/packages/create-block/lib/index.js @@ -3,72 +3,68 @@ */ const program = require( 'commander' ); const inquirer = require( 'inquirer' ); +const { startCase } = require( 'lodash' ); /** * Internal dependencies */ const CLIError = require( './cli-error' ); -const { - error, - info, -} = require( './log' ); +const log = require( './log' ); const { version } = require( '../package.json' ); const scaffold = require( './scaffold' ); -const { - getDefaultAnswers, - getPrompts, -} = require( './templates' ); -const { startCase } = require( './utils' ); +const { getDefaultValues, getPrompts } = require( './templates' ); const commandName = `wp-create-block`; program .name( commandName ) .description( 'Generates PHP, JS and CSS code for registering a block for a WordPress plugin.\n\n' + - '[slug] is optional. When provided it triggers the quick mode where it is used ' + - 'as the block slug used for its identification, the output location for scaffolded files, ' + - 'and the name of the WordPress plugin. The rest of the configuration is set to all default values.' + '[slug] is optional. When provided it triggers the quick mode where it is used ' + + 'as the block slug used for its identification, the output location for scaffolded files, ' + + 'and the name of the WordPress plugin. The rest of the configuration is set to all default values.' ) .version( version ) .arguments( '[slug]' ) - .option( '-t, --template ', 'template type name, allowed values: "es5", "esnext"', 'esnext' ) + .option( + '-t, --template ', + 'template type name, allowed values: "es5", "esnext"', + 'esnext' + ) .action( async ( slug, { template } ) => { try { - const defaultAnswers = getDefaultAnswers( template ); + const defaultValues = getDefaultValues( template ); if ( slug ) { - const title = defaultAnswers.slug === slug ? - defaultAnswers.title : - startCase( slug.replace( /-/, ' ' ) ); const answers = { - ...defaultAnswers, + ...defaultValues, slug, - title, + // Transforms slug to title. + title: startCase( slug ), }; await scaffold( template, answers ); } else { const answers = await inquirer.prompt( getPrompts( template ) ); await scaffold( template, { - ...defaultAnswers, + ...defaultValues, ...answers, } ); } - } catch ( e ) { - if ( e instanceof CLIError ) { - info( '' ); - error( e.message ); + } catch ( error ) { + if ( error instanceof CLIError ) { + log.info( '' ); + log.error( error.message ); process.exit( 1 ); } else { - throw e; + throw error; } } } ); program.on( '--help', function() { - info( '' ); - info( 'Examples:' ); - info( ` $ ${ commandName }` ); - info( ` $ ${ commandName } todo-list` ); - info( ` $ ${ commandName } --template es5 todo-list` ); + log.info( '' ); + log.info( 'Examples:' ); + log.info( ` $ ${ commandName }` ); + log.info( ` $ ${ commandName } todo-list` ); + log.info( ` $ ${ commandName } --template es5 todo-list` ); } ); program.parse( process.argv ); diff --git a/packages/create-block/lib/init-wp-scripts.js b/packages/create-block/lib/init-wp-scripts.js index 9e9b9c47795b8..2ce2ecf57d077 100644 --- a/packages/create-block/lib/init-wp-scripts.js +++ b/packages/create-block/lib/init-wp-scripts.js @@ -2,7 +2,6 @@ * External dependencies */ const { command } = require( 'execa' ); -const { install } = require( 'pkg-install' ); const { join } = require( 'path' ); const writePkg = require( 'write-pkg' ); @@ -11,7 +10,7 @@ const writePkg = require( 'write-pkg' ); */ const { info } = require( './log' ); -module.exports = async function( { author, license, slug, title, version } ) { +module.exports = async function( { author, description, license, slug, version } ) { const cwd = join( process.cwd(), slug ); info( '' ); @@ -19,7 +18,7 @@ module.exports = async function( { author, license, slug, title, version } ) { await writePkg( cwd, { name: slug, version, - description: title, + description, author, license, main: 'build/index.js', @@ -34,12 +33,8 @@ module.exports = async function( { author, license, slug, title, version } ) { info( '' ); info( 'Installing packages. It might take a couple of minutes.' ); - await install( [ - '@wordpress/scripts', - ], { + await command( 'npm install @wordpress/scripts --save-dev', { cwd, - dev: true, - prefer: 'npm', } ); info( '' ); diff --git a/packages/create-block/lib/log.js b/packages/create-block/lib/log.js index e99a57741510e..b5cc9dc21108c 100644 --- a/packages/create-block/lib/log.js +++ b/packages/create-block/lib/log.js @@ -4,12 +4,6 @@ */ const chalk = require( 'chalk' ); -const clear = () => { - process.stdout.write( - process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H' - ); -}; - const code = ( input ) => { console.log( chalk.cyan( input ) ); }; @@ -27,7 +21,6 @@ const success = ( input ) => { module.exports = { code, - clear, error, info, success, diff --git a/packages/create-block/lib/prompts.js b/packages/create-block/lib/prompts.js index 9315787625465..e0e407148f164 100644 --- a/packages/create-block/lib/prompts.js +++ b/packages/create-block/lib/prompts.js @@ -1,7 +1,7 @@ /** - * Internal dependencies + * External dependencies */ -const { upperFirst } = require( './utils' ); +const { upperFirst } = require( 'lodash' ); const slug = { type: 'input', @@ -59,8 +59,7 @@ const dashicon = { return true; }, filter( input ) { - return input && - input.replace( /dashicon(s)?-/, '' ); + return input && input.replace( /dashicon(s)?-/, '' ); }, }; diff --git a/packages/create-block/lib/scaffold.js b/packages/create-block/lib/scaffold.js index 94dee8557283b..7374fbf4f82ec 100644 --- a/packages/create-block/lib/scaffold.js +++ b/packages/create-block/lib/scaffold.js @@ -5,33 +5,30 @@ const { dirname, join } = require( 'path' ); const makeDir = require( 'make-dir' ); const { readFile, writeFile } = require( 'fs' ).promises; const { render } = require( 'mustache' ); +const { snakeCase } = require( 'lodash' ); /** * Internal dependencies */ const initWPScripts = require( './init-wp-scripts' ); -const { code, clear, info, success } = require( './log' ); +const { code, info, success } = require( './log' ); const { hasWPScriptsEnabled, getOutputFiles } = require( './templates' ); -module.exports = async function( templateName, { - namespace, - slug, - title, - description, - dashicon, - category, - author, - license, - version, -} ) { - clear(); +module.exports = async function( + templateName, + { namespace, slug, title, description, dashicon, category, author, license, version } +) { + slug = slug.toLowerCase(); + namespace = namespace.toLowerCase(); + + info( '' ); info( `Creating a new WordPress block in "${ slug }" folder.` ); - const outputFiles = getOutputFiles( templateName ); const view = { namespace, + namespaceSnakeCase: snakeCase( namespace ), slug, - machineName: `${ namespace }_${ slug }`.replace( /\-/g, '_' ), + slugSnakeCase: snakeCase( slug ), title, description, dashicon, @@ -41,19 +38,16 @@ module.exports = async function( templateName, { license, textdomain: namespace, }; - await Promise.all( - Object.keys( outputFiles ).map( async ( fileName ) => { + getOutputFiles( templateName ).map( async ( file ) => { const template = await readFile( - join( __dirname, `templates/${ outputFiles[ fileName ] }.mustache` ), + join( __dirname, `templates/${ templateName }/${ file }.mustache` ), 'utf8' ); - const filePath = `${ slug }/${ fileName.replace( /\$slug/g, slug ) }`; - await makeDir( dirname( filePath ) ); - writeFile( - filePath, - render( template, view ) - ); + // Output files can have names that depend on the slug provided. + const outputFilePath = `${ slug }/${ file.replace( /\$slug/g, slug ) }`; + await makeDir( dirname( outputFilePath ) ); + writeFile( outputFilePath, render( template, view ) ); } ) ); @@ -61,8 +55,8 @@ module.exports = async function( templateName, { await initWPScripts( view ); } - clear(); - success( `Done: block '${ title }' bootstrapped in "${ slug }" folder.` ); + info( '' ); + success( `Done: block "${ title }" bootstrapped in the "${ slug }" folder.` ); if ( hasWPScriptsEnabled( templateName ) ) { info( '' ); info( 'Inside that directory, you can run several commands:' ); diff --git a/packages/create-block/lib/templates.js b/packages/create-block/lib/templates.js index 014ebb1a724d5..4a4b7c4b50c6a 100644 --- a/packages/create-block/lib/templates.js +++ b/packages/create-block/lib/templates.js @@ -13,7 +13,7 @@ const version = '0.1.0'; const templates = { es5: { - defaultAnswers: { + defaultValues: { namespace, slug: 'es5-example', title: 'ES5 Example', @@ -24,34 +24,29 @@ const templates = { license, version, }, - outputFiles: { - '.editorconfig': 'editorconfig', - 'editor.css': 'editor-css', - 'index.js': 'es5/index-js', - '$slug.php': 'es5/plugin-php', - 'style.css': 'style-css', - }, + outputFiles: [ '.editorconfig', 'editor.css', 'index.js', '$slug.php', 'style.css' ], }, esnext: { - defaultAnswers: { + defaultValues: { namespace, slug: 'esnext-example', title: 'ESNext Example', - description: 'Example block written with ESNext standard and JSX support – build step required.', + description: + 'Example block written with ESNext standard and JSX support – build step required.', dashicon, category, author, license, version, }, - outputFiles: { - '.editorconfig': 'editorconfig', - '.gitignore': 'gitignore', - 'editor.css': 'editor-css', - 'src/index.js': 'esnext/index-js', - '$slug.php': 'esnext/plugin-php', - 'style.css': 'style-css', - }, + outputFiles: [ + '.editorconfig', + '.gitignore', + 'editor.css', + 'src/index.js', + '$slug.php', + 'style.css', + ], wpScriptsEnabled: true, }, }; @@ -59,15 +54,14 @@ const templates = { const getTemplate = ( templateName ) => { if ( ! templates[ templateName ] ) { throw new CliError( - 'Invalid template type name.' + - ` Allowed values: ${ Object.keys( templates ).join( ', ' ) }.` + `Invalid template type name. Allowed values: ${ Object.keys( templates ).join( ', ' ) }.` ); } return templates[ templateName ]; }; -const getDefaultAnswers = ( templateName ) => { - return getTemplate( templateName ).defaultAnswers; +const getDefaultValues = ( templateName ) => { + return getTemplate( templateName ).defaultValues; }; const getOutputFiles = ( templateName ) => { @@ -75,11 +69,11 @@ const getOutputFiles = ( templateName ) => { }; const getPrompts = ( templateName ) => { - const defaultAnswers = getDefaultAnswers( templateName ); + const defaultValues = getDefaultValues( templateName ); return Object.keys( prompts ).map( ( promptName ) => { return { ...prompts[ promptName ], - default: defaultAnswers[ promptName ], + default: defaultValues[ promptName ], }; } ); }; @@ -89,7 +83,7 @@ const hasWPScriptsEnabled = ( templateName ) => { }; module.exports = { - getDefaultAnswers, + getDefaultValues, getOutputFiles, getPrompts, hasWPScriptsEnabled, diff --git a/packages/create-block/lib/templates/es5/plugin-php.mustache b/packages/create-block/lib/templates/es5/$slug.php.mustache similarity index 90% rename from packages/create-block/lib/templates/es5/plugin-php.mustache rename to packages/create-block/lib/templates/es5/$slug.php.mustache index 1dae2fd43a4f7..4a9a0c6bceaa6 100644 --- a/packages/create-block/lib/templates/es5/plugin-php.mustache +++ b/packages/create-block/lib/templates/es5/$slug.php.mustache @@ -16,7 +16,7 @@ * * @see https://developer.wordpress.org/block-editor/tutorials/block-tutorial/applying-styles-with-stylesheets/ */ -function {{machineName}}_block_init() { +function {{namespaceSnakeCase}}_{{slugSnakeCase}}_block_init() { $dir = dirname( __FILE__ ); $index_js = 'index.js'; @@ -53,4 +53,4 @@ function {{machineName}}_block_init() { 'style' => '{{namespace}}-{{slug}}-block', ) ); } -add_action( 'init', '{{machineName}}_block_init' ); +add_action( 'init', '{{namespaceSnakeCase}}_{{slugSnakeCase}}_block_init' ); diff --git a/packages/create-block/lib/templates/editorconfig.mustache b/packages/create-block/lib/templates/es5/.editorconfig.mustache similarity index 92% rename from packages/create-block/lib/templates/editorconfig.mustache rename to packages/create-block/lib/templates/es5/.editorconfig.mustache index de75f444cfd0c..a541e47e767bc 100644 --- a/packages/create-block/lib/templates/editorconfig.mustache +++ b/packages/create-block/lib/templates/es5/.editorconfig.mustache @@ -12,9 +12,8 @@ end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true indent_style = tab -indent_size = 4 -[{*.json,*.yml}] +[*.yml] indent_style = space indent_size = 2 diff --git a/packages/create-block/lib/templates/editor-css.mustache b/packages/create-block/lib/templates/es5/editor.css.mustache similarity index 100% rename from packages/create-block/lib/templates/editor-css.mustache rename to packages/create-block/lib/templates/es5/editor.css.mustache diff --git a/packages/create-block/lib/templates/es5/index-js.mustache b/packages/create-block/lib/templates/es5/index.js.mustache similarity index 100% rename from packages/create-block/lib/templates/es5/index-js.mustache rename to packages/create-block/lib/templates/es5/index.js.mustache diff --git a/packages/create-block/lib/templates/style-css.mustache b/packages/create-block/lib/templates/es5/style.css.mustache similarity index 100% rename from packages/create-block/lib/templates/style-css.mustache rename to packages/create-block/lib/templates/es5/style.css.mustache diff --git a/packages/create-block/lib/templates/esnext/plugin-php.mustache b/packages/create-block/lib/templates/esnext/$slug.php.mustache similarity index 91% rename from packages/create-block/lib/templates/esnext/plugin-php.mustache rename to packages/create-block/lib/templates/esnext/$slug.php.mustache index 5e848808942c8..13e3c9c987619 100644 --- a/packages/create-block/lib/templates/esnext/plugin-php.mustache +++ b/packages/create-block/lib/templates/esnext/$slug.php.mustache @@ -16,7 +16,7 @@ * * @see https://developer.wordpress.org/block-editor/tutorials/block-tutorial/applying-styles-with-stylesheets/ */ -function {{machineName}}_block_init() { +function {{namespaceSnakeCase}}_{{slugSnakeCase}}_block_init() { $dir = dirname( __FILE__ ); $script_asset_path = "$dir/build/index.asset.php"; @@ -56,4 +56,4 @@ function {{machineName}}_block_init() { 'style' => '{{namespace}}-{{slug}}-block', ) ); } -add_action( 'init', '{{machineName}}_block_init' ); +add_action( 'init', '{{namespaceSnakeCase}}_{{slugSnakeCase}}_block_init' ); diff --git a/packages/create-block/lib/templates/esnext/.editorconfig.mustache b/packages/create-block/lib/templates/esnext/.editorconfig.mustache new file mode 100644 index 0000000000000..a541e47e767bc --- /dev/null +++ b/packages/create-block/lib/templates/esnext/.editorconfig.mustache @@ -0,0 +1,21 @@ +# This file is for unifying the coding style for different editors and IDEs +# editorconfig.org + +# WordPress Coding Standards +# https://make.wordpress.org/core/handbook/coding-standards/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = tab + +[*.yml] +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false diff --git a/packages/create-block/lib/templates/gitignore.mustache b/packages/create-block/lib/templates/esnext/.gitignore.mustache similarity index 100% rename from packages/create-block/lib/templates/gitignore.mustache rename to packages/create-block/lib/templates/esnext/.gitignore.mustache diff --git a/packages/create-block/lib/templates/esnext/editor.css.mustache b/packages/create-block/lib/templates/esnext/editor.css.mustache new file mode 100644 index 0000000000000..fc68223e00660 --- /dev/null +++ b/packages/create-block/lib/templates/esnext/editor.css.mustache @@ -0,0 +1,9 @@ +/** + * The following styles get applied inside the editor only. + * + * Replace them with your own styles or remove the file completely. + */ + +.wp-block-{{namespace}}-{{slug}} { + border: 1px dotted #f00; +} diff --git a/packages/create-block/lib/templates/esnext/index-js.mustache b/packages/create-block/lib/templates/esnext/src/index.js.mustache similarity index 100% rename from packages/create-block/lib/templates/esnext/index-js.mustache rename to packages/create-block/lib/templates/esnext/src/index.js.mustache diff --git a/packages/create-block/lib/templates/esnext/style.css.mustache b/packages/create-block/lib/templates/esnext/style.css.mustache new file mode 100644 index 0000000000000..76b12185cee07 --- /dev/null +++ b/packages/create-block/lib/templates/esnext/style.css.mustache @@ -0,0 +1,12 @@ +/** + * The following styles get applied both on the front of your site + * and in the editor. + * + * Replace them with your own styles or remove the file completely. + */ + +.wp-block-{{namespace}}-{{slug}} { + background-color: #000; + color: #fff; + padding: 2px; +} diff --git a/packages/create-block/lib/test/utils.js b/packages/create-block/lib/test/utils.js deleted file mode 100644 index 714683e4880b3..0000000000000 --- a/packages/create-block/lib/test/utils.js +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Internal dependencies - */ -import { - startCase, - upperFirst, -} from '../utils'; - -describe( 'startCase', () => { - test( 'words get converted to start with upper case', () => { - expect( - startCase( 'hello world' ) - ).toBe( - 'Hello World' - ); - } ); -} ); - -describe( 'upperFirst', () => { - test( 'First char gets converted to upper case', () => { - expect( - upperFirst( 'hello world' ) - ).toBe( - 'Hello world' - ); - } ); -} ); diff --git a/packages/create-block/lib/utils.js b/packages/create-block/lib/utils.js deleted file mode 100644 index e778807318430..0000000000000 --- a/packages/create-block/lib/utils.js +++ /dev/null @@ -1,12 +0,0 @@ -const startCase = ( input ) => { - return input.split( ' ' ).map( upperFirst ).join( ' ' ); -}; - -const upperFirst = ( input ) => { - return input.charAt( 0 ).toUpperCase() + input.slice( 1 ); -}; - -module.exports = { - startCase, - upperFirst, -}; diff --git a/packages/create-block/package.json b/packages/create-block/package.json index dfce7c65ea8dc..b438e113fc86f 100644 --- a/packages/create-block/package.json +++ b/packages/create-block/package.json @@ -1,45 +1,45 @@ { - "name": "@wordpress/create-block", - "version": "0.5.1", - "description": "Generates PHP, JS and CSS code for registering a block for a WordPress plugin.", - "author": "The WordPress Contributors", - "license": "GPL-2.0-or-later", - "keywords": [ - "wordpress", - "block", - "scaffold" - ], - "homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/create-block/README.md", - "repository": { - "type": "git", - "url": "https://github.com/WordPress/gutenberg.git", - "directory": "packages/create-block" - }, - "bugs": { - "url": "https://github.com/WordPress/gutenberg/issues" - }, - "engines": { - "node": ">=10.0", - "npm": ">=6.1" - }, - "files": [ - "lib" - ], - "main": "index.js", - "bin": { - "wp-create-block": "./index.js" - }, - "dependencies": { - "chalk": "^2.4.2", - "commander": "^4.1.0", - "execa": "^4.0.0", - "inquirer": "^7.0.3", - "make-dir": "^3.0.0", - "mustache": "^4.0.0", - "pkg-install": "^1.0.0", - "write-pkg": "^4.0.0" - }, - "publishConfig": { - "access": "public" - } + "name": "@wordpress/create-block", + "version": "0.5.1", + "description": "Generates PHP, JS and CSS code for registering a block for a WordPress plugin.", + "author": "The WordPress Contributors", + "license": "GPL-2.0-or-later", + "keywords": [ + "wordpress", + "block", + "scaffold" + ], + "homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/create-block/README.md", + "repository": { + "type": "git", + "url": "https://github.com/WordPress/gutenberg.git", + "directory": "packages/create-block" + }, + "bugs": { + "url": "https://github.com/WordPress/gutenberg/issues" + }, + "engines": { + "node": ">=10.0", + "npm": ">=6.1" + }, + "files": [ + "lib" + ], + "main": "index.js", + "bin": { + "wp-create-block": "./index.js" + }, + "dependencies": { + "chalk": "^2.4.2", + "commander": "^4.1.0", + "execa": "^4.0.0", + "inquirer": "^7.0.3", + "lodash": "^4.17.15", + "make-dir": "^3.0.0", + "mustache": "^4.0.0", + "write-pkg": "^4.0.0" + }, + "publishConfig": { + "access": "public" + } }