newspack-scripts 1.0.2 → 1.1.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.
- package/bin/newspack-scripts.js +1 -1
- package/config/getWebpackConfig.js +3 -0
- package/package.json +5 -2
- package/scripts/build.js +10 -0
- package/scripts/start.js +10 -0
- package/scripts/test.js +6 -8
- package/scripts/utils/babelJestTransformer.js +13 -0
- package/scripts/utils/{jest-setup.js → jestSetup.js} +0 -0
- package/scripts/utils/modules.js +7 -0
package/bin/newspack-scripts.js
CHANGED
|
@@ -4,7 +4,7 @@ const spawn = require("cross-spawn");
|
|
|
4
4
|
|
|
5
5
|
const [scriptName, ...nodeArgs] = process.argv.slice(2);
|
|
6
6
|
|
|
7
|
-
if (["test"].includes(scriptName)) {
|
|
7
|
+
if (["test", "build", "start"].includes(scriptName)) {
|
|
8
8
|
const result = spawn.sync(
|
|
9
9
|
process.execPath,
|
|
10
10
|
[require.resolve("../scripts/" + scriptName), ...nodeArgs],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newspack-scripts",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"bin": {
|
|
6
6
|
"newspack-scripts": "./bin/newspack-scripts.js"
|
|
@@ -8,12 +8,15 @@
|
|
|
8
8
|
"author": "",
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"dependencies": {
|
|
11
|
+
"@automattic/calypso-build": "^10.0.0",
|
|
12
|
+
"@babel/preset-env": "^7.16.4",
|
|
11
13
|
"@testing-library/jest-dom": "^5.15.1",
|
|
12
14
|
"@testing-library/react": "^12.1.2",
|
|
13
15
|
"babel-jest": "^27.4.2",
|
|
14
16
|
"cross-spawn": "^7.0.3",
|
|
15
17
|
"jest": "^27.4.3",
|
|
16
|
-
"jest-environment-jsdom": "^27.4.3"
|
|
18
|
+
"jest-environment-jsdom": "^27.4.3",
|
|
19
|
+
"webpack": "^5.65.0"
|
|
17
20
|
},
|
|
18
21
|
"scripts": {
|
|
19
22
|
"semantic-release": "semantic-release"
|
package/scripts/build.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const spawn = require("cross-spawn");
|
|
4
|
+
const modules = require("./utils/modules");
|
|
5
|
+
|
|
6
|
+
spawn.sync(process.execPath, [modules.calypsoBuild], {
|
|
7
|
+
cwd: modules.rootDirectory,
|
|
8
|
+
stdio: "inherit",
|
|
9
|
+
env: { ...process.env, NODE_ENV: "production" }
|
|
10
|
+
});
|
package/scripts/start.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const spawn = require("cross-spawn");
|
|
4
|
+
const modules = require("./utils/modules");
|
|
5
|
+
|
|
6
|
+
spawn.sync(process.execPath, [modules.calypsoBuild, "--watch"], {
|
|
7
|
+
cwd: modules.rootDirectory,
|
|
8
|
+
stdio: "inherit",
|
|
9
|
+
env: { ...process.env, NODE_ENV: "development" }
|
|
10
|
+
});
|
package/scripts/test.js
CHANGED
|
@@ -4,24 +4,22 @@ process.env.BABEL_ENV = "test";
|
|
|
4
4
|
process.env.NODE_ENV = "test";
|
|
5
5
|
|
|
6
6
|
const jest = require("jest");
|
|
7
|
-
const fs = require("fs");
|
|
8
7
|
const path = require("path");
|
|
9
|
-
const execSync = require("child_process").execSync;
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
const modules = require("./utils/modules");
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
let argv = process.argv.slice(2);
|
|
14
12
|
|
|
15
13
|
const JEST_CONFIG = {
|
|
16
|
-
rootDir:
|
|
17
|
-
setupFilesAfterEnv: [path.resolve(__dirname, "utils/
|
|
14
|
+
rootDir: modules.rootDirectory,
|
|
15
|
+
setupFilesAfterEnv: [path.resolve(__dirname, "utils/jestSetup.js")],
|
|
18
16
|
testMatch: ["<rootDir>/**/*test.js?(x)"],
|
|
19
17
|
transform: {
|
|
20
|
-
"^.+\\.js?$": "
|
|
18
|
+
"^.+\\.js?$": path.resolve(__dirname, "utils/babelJestTransformer.js")
|
|
21
19
|
},
|
|
22
20
|
transformIgnorePatterns: ["/node_modules/(?!newspack-scripts/)"],
|
|
23
21
|
moduleNameMapper: {
|
|
24
|
-
"\\.(scss|css)$": "
|
|
22
|
+
"\\.(scss|css)$": path.resolve(__dirname, "utils/babelJestTransformer.js")
|
|
25
23
|
},
|
|
26
24
|
testEnvironment: "jsdom",
|
|
27
25
|
collectCoverageFrom: [
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const babelJest = require("babel-jest").default;
|
|
4
|
+
|
|
5
|
+
module.exports = babelJest.createTransformer({
|
|
6
|
+
presets: [
|
|
7
|
+
require.resolve("@babel/preset-env"),
|
|
8
|
+
require.resolve("@automattic/calypso-build/babel/default"),
|
|
9
|
+
require.resolve("@automattic/calypso-build/babel/wordpress-element")
|
|
10
|
+
],
|
|
11
|
+
babelrc: false,
|
|
12
|
+
configFile: false
|
|
13
|
+
});
|
|
File without changes
|