@lipemat/js-boilerplate 10.4.0-beta.3 → 10.4.0-beta.5
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/lipemat-js-boilerplate.js +1 -5
- package/config/jest.config.js +8 -15
- package/helpers/{config.ts → config.js} +8 -9
- package/helpers/{package-config.ts → package-config.js} +7 -9
- package/package.json +1 -3
- package/scripts/test.js +27 -0
- package/tsconfig.json +2 -5
- package/config/jest.config.ts +0 -51
- package/scripts/test.ts +0 -24
|
@@ -15,10 +15,6 @@ const scriptIndex = args.findIndex(
|
|
|
15
15
|
const script = -1 === scriptIndex ? args[ 0 ] : args[ scriptIndex ];
|
|
16
16
|
const nodeArgs = scriptIndex > 0 ? args.slice( 0, scriptIndex ) : [];
|
|
17
17
|
|
|
18
|
-
const TS_CONVERTED = [
|
|
19
|
-
'test',
|
|
20
|
-
];
|
|
21
|
-
|
|
22
18
|
switch ( script ) {
|
|
23
19
|
case 'browserslist':
|
|
24
20
|
case 'dist':
|
|
@@ -36,7 +32,7 @@ switch ( script ) {
|
|
|
36
32
|
const result = spawn.sync(
|
|
37
33
|
'ts-node',
|
|
38
34
|
nodeArgs
|
|
39
|
-
.concat( require.resolve( '../scripts/' + script
|
|
35
|
+
.concat( require.resolve( '../scripts/' + script ) )
|
|
40
36
|
.concat( args.slice( scriptIndex + 1 ) ),
|
|
41
37
|
{stdio: 'inherit'}
|
|
42
38
|
);
|
package/config/jest.config.js
CHANGED
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* @deprecated
|
|
5
|
-
*
|
|
6
|
-
* @todo Remove on next major release.
|
|
7
|
-
*
|
|
8
|
-
* @see jest.config.ts
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
// Necessary because some of the boilerplate code is written in TypeScript.
|
|
12
|
-
require( 'ts-node/register' );
|
|
1
|
+
// So we have something to check against for adjusting things like babel.config.js.
|
|
2
|
+
global.__TEST__ = true;
|
|
13
3
|
|
|
14
4
|
const path = require( 'path' );
|
|
15
|
-
const packageConfig = require( '../helpers/package-config
|
|
5
|
+
const packageConfig = require( '../helpers/package-config' );
|
|
16
6
|
const fs = require( 'fs' );
|
|
17
7
|
|
|
18
|
-
const babelConfig = require( '../helpers/config
|
|
8
|
+
const babelConfig = require( '../helpers/config' ).getConfig( 'babel.config' );
|
|
19
9
|
delete babelConfig.cacheDirectory;
|
|
20
10
|
|
|
21
11
|
let jestConfig = {
|
|
@@ -38,15 +28,18 @@ let jestConfig = {
|
|
|
38
28
|
'^.+\\.[tj]sx?$': [ 'babel-jest', babelConfig ],
|
|
39
29
|
},
|
|
40
30
|
setupFilesAfterEnv: [
|
|
31
|
+
// @todo Remove old "tests" directory on next major release.
|
|
41
32
|
path.resolve( packageConfig.workingDirectory, 'tests/setup.js' ),
|
|
42
33
|
path.resolve( packageConfig.workingDirectory, 'tests/setup.ts' ),
|
|
34
|
+
|
|
35
|
+
// New location.
|
|
43
36
|
path.resolve( packageConfig.workingDirectory, 'jest/setup.ts' ),
|
|
44
37
|
].filter( fs.existsSync ),
|
|
45
38
|
};
|
|
46
39
|
|
|
47
40
|
/**
|
|
48
41
|
* Allows overriding configurations in the project `/config/jest.config.js` file.
|
|
49
|
-
* We don't actually need to do this because `jest.config.
|
|
42
|
+
* We don't actually need to do this because `jest.config.js` in the project root
|
|
50
43
|
* is already an override of this file, but we support it anyway to keep things consistent.
|
|
51
44
|
*/
|
|
52
45
|
try {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
const packageConfig = require( './package-config' );
|
|
2
2
|
const path = require( 'path' );
|
|
3
3
|
const browserslist = require( 'browserslist' );
|
|
4
4
|
const fs = require( 'fs' );
|
|
5
|
+
const config = require( './package-config' );
|
|
5
6
|
|
|
6
7
|
const extensions = [
|
|
7
|
-
...Object.keys(
|
|
8
|
-
...Object.keys(
|
|
8
|
+
...Object.keys( packageConfig.dependencies ?? {} ).filter( name => name.includes( 'js-boilerplate-' ) ),
|
|
9
|
+
...Object.keys( packageConfig.devDependencies ?? {} ).filter( name => name.includes( 'js-boilerplate-' ) ),
|
|
9
10
|
];
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -18,7 +19,6 @@ const extensions = [
|
|
|
18
19
|
*/
|
|
19
20
|
function hasLocalOverride( fileName, inWorkingDirectory = false, ) {
|
|
20
21
|
let hasLocal = false;
|
|
21
|
-
const packageConfig = getPackageConfig();
|
|
22
22
|
try {
|
|
23
23
|
if ( inWorkingDirectory ) {
|
|
24
24
|
require( path.resolve( packageConfig.workingDirectory, fileName ) );
|
|
@@ -62,7 +62,6 @@ function hasLocalOverride( fileName, inWorkingDirectory = false, ) {
|
|
|
62
62
|
* @return {Object}
|
|
63
63
|
*/
|
|
64
64
|
function getConfig( fileName ) {
|
|
65
|
-
const packageConfig = getPackageConfig();
|
|
66
65
|
let mergedConfig = require( '../config/' + fileName );
|
|
67
66
|
mergedConfig = {...mergedConfig, ...getExtensionsConfig( fileName, mergedConfig )};
|
|
68
67
|
try {
|
|
@@ -118,15 +117,14 @@ function getExtensionsConfig( fileName, defaultConfig ) {
|
|
|
118
117
|
* @return {string}
|
|
119
118
|
*/
|
|
120
119
|
function getTsConfigFile() {
|
|
121
|
-
const packageConfig = getPackageConfig();
|
|
122
120
|
const possibles = [
|
|
123
121
|
// Backward compatible for before @lipemat/eslint-config version 3.
|
|
124
|
-
path.resolve(
|
|
125
|
-
path.resolve(
|
|
122
|
+
path.resolve( config.workingDirectory + '/tsconfig.json' ),
|
|
123
|
+
path.resolve( config.packageDirectory + '/tsconfig.json' ),
|
|
126
124
|
];
|
|
127
125
|
let tsConfig = '';
|
|
128
126
|
possibles.forEach( filePath => {
|
|
129
|
-
if (
|
|
127
|
+
if ( fs.existsSync( filePath ) ) {
|
|
130
128
|
tsConfig = filePath;
|
|
131
129
|
}
|
|
132
130
|
} );
|
|
@@ -173,6 +171,7 @@ const getDefaultBrowsersList = () => {
|
|
|
173
171
|
return false;
|
|
174
172
|
};
|
|
175
173
|
|
|
174
|
+
|
|
176
175
|
module.exports = {
|
|
177
176
|
getBrowsersList,
|
|
178
177
|
getConfig,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const path = require( 'path' );
|
|
2
|
+
const fs = require( 'fs' );
|
|
3
3
|
|
|
4
|
-
const workingDirectory = realpathSync( process.cwd() );
|
|
5
|
-
let packageConfig = require( resolve( workingDirectory, 'package.json' ) );
|
|
4
|
+
const workingDirectory = fs.realpathSync( process.cwd() );
|
|
5
|
+
let packageConfig = require( path.resolve( workingDirectory, 'package.json' ) );
|
|
6
6
|
packageConfig.brotliFiles ||= false;
|
|
7
7
|
packageConfig.es6Modules ||= [];
|
|
8
8
|
packageConfig.jsPath ||= '';
|
|
@@ -10,11 +10,11 @@ packageConfig.jsPath ||= '';
|
|
|
10
10
|
packageConfig.packageDirectory = workingDirectory;
|
|
11
11
|
packageConfig.url ||= 'http://localhost';
|
|
12
12
|
// Path of JS application files.
|
|
13
|
-
packageConfig.workingDirectory = packageConfig.jsPath !== '' ? resolve( packageConfig.jsPath ) : workingDirectory;
|
|
13
|
+
packageConfig.workingDirectory = packageConfig.jsPath !== '' ? path.resolve( packageConfig.jsPath ) : workingDirectory;
|
|
14
14
|
packageConfig.shortCssClasses ||= false;
|
|
15
15
|
|
|
16
16
|
try {
|
|
17
|
-
const localConfig = require( resolve( workingDirectory, './local-config.json' ) );
|
|
17
|
+
const localConfig = require( path.resolve( workingDirectory, './local-config.json' ) );
|
|
18
18
|
packageConfig = {...packageConfig, ...localConfig};
|
|
19
19
|
} catch ( e ) {
|
|
20
20
|
}
|
|
@@ -27,11 +27,9 @@ try {
|
|
|
27
27
|
*
|
|
28
28
|
* @since 10.3.0
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
function getPackageConfig() {
|
|
31
31
|
return packageConfig;
|
|
32
32
|
}
|
|
33
33
|
packageConfig.getPackageConfig = getPackageConfig;
|
|
34
34
|
|
|
35
|
-
// Leaving old export structure for backwards compatibility.
|
|
36
|
-
// @todo Remove in favor of default export in version 11.
|
|
37
35
|
module.exports = packageConfig;
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lipemat/js-boilerplate",
|
|
3
|
-
"version": "10.4.0-beta.
|
|
3
|
+
"version": "10.4.0-beta.5",
|
|
4
4
|
"description": "Dependencies and scripts for a no config JavaScript app",
|
|
5
5
|
"author": "Mat Lipe",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"type": "commonjs",
|
|
8
7
|
"engines": {
|
|
9
8
|
"node": ">=16.14.2"
|
|
10
9
|
},
|
|
@@ -79,7 +78,6 @@
|
|
|
79
78
|
"react-dom": "^18.2.0",
|
|
80
79
|
"react-refresh": "^0.14.0",
|
|
81
80
|
"style-loader": "^3.3.1",
|
|
82
|
-
"ts-node": "^10.9.1",
|
|
83
81
|
"typescript": "^5.1.3",
|
|
84
82
|
"update-notifier": "^4.1.3",
|
|
85
83
|
"webpack": "^5.72.1",
|
package/scripts/test.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const {resolve: pathResolve} = require( 'path' );
|
|
2
|
+
const {existsSync} = require( 'fs' );
|
|
3
|
+
|
|
4
|
+
const {getPackageConfig} = require( '../helpers/package-config' );
|
|
5
|
+
|
|
6
|
+
const packageConfig = getPackageConfig();
|
|
7
|
+
|
|
8
|
+
const possibleConfig = [
|
|
9
|
+
// @todo Remove pulling from the root on next major release.
|
|
10
|
+
pathResolve( packageConfig.workingDirectory + '/jest.config.ts' ),
|
|
11
|
+
pathResolve( packageConfig.workingDirectory + '/jest.config.js' ),
|
|
12
|
+
|
|
13
|
+
// New location.
|
|
14
|
+
pathResolve( packageConfig.workingDirectory + '/jest/jest.config.ts' ),
|
|
15
|
+
pathResolve( packageConfig.workingDirectory + '/jest/jest.config.js' ),
|
|
16
|
+
].filter( existsSync );
|
|
17
|
+
|
|
18
|
+
if ( possibleConfig.length < 1 ) {
|
|
19
|
+
throw new Error( 'You must have a `jest.config.[tj]s` file in the root of your project or in the `jest` folder.' );
|
|
20
|
+
} else {
|
|
21
|
+
const file = possibleConfig.shift();
|
|
22
|
+
if ( undefined !== file ) {
|
|
23
|
+
process.argv.push( '--config', file );
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
require( 'jest-cli/bin/jest' );
|
package/tsconfig.json
CHANGED
package/config/jest.config.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type {Config} from 'jest';
|
|
2
|
-
import {resolve} from 'path';
|
|
3
|
-
const {getPackageConfig} = require( '../helpers/package-config' );
|
|
4
|
-
const {existsSync} = require( 'fs' );
|
|
5
|
-
const {getConfig} = require( '../helpers/config' );
|
|
6
|
-
|
|
7
|
-
const packageConfig = getPackageConfig();
|
|
8
|
-
const babelConfig = getConfig( 'babel.config' );
|
|
9
|
-
delete babelConfig.cacheDirectory;
|
|
10
|
-
|
|
11
|
-
let jestConfig: Config = {
|
|
12
|
-
globals: {
|
|
13
|
-
__TEST__: true,
|
|
14
|
-
},
|
|
15
|
-
moduleNameMapper: {
|
|
16
|
-
'\\.(pcss|less|css)$': 'identity-obj-proxy',
|
|
17
|
-
'is-plain-obj': 'identity-obj-proxy',
|
|
18
|
-
uuid: 'identity-obj-proxy',
|
|
19
|
-
},
|
|
20
|
-
roots: [
|
|
21
|
-
'./tests',
|
|
22
|
-
],
|
|
23
|
-
testEnvironment: 'jsdom',
|
|
24
|
-
testEnvironmentOptions: {
|
|
25
|
-
url: packageConfig.url,
|
|
26
|
-
},
|
|
27
|
-
transform: {
|
|
28
|
-
'^.+\\.[tj]sx?$': [ 'babel-jest', babelConfig ],
|
|
29
|
-
},
|
|
30
|
-
setupFilesAfterEnv: [
|
|
31
|
-
// @todo Remove old "tests" directory on next major release.
|
|
32
|
-
resolve( packageConfig.workingDirectory, 'tests/setup.js' ),
|
|
33
|
-
resolve( packageConfig.workingDirectory, 'tests/setup.ts' ),
|
|
34
|
-
|
|
35
|
-
// New location.
|
|
36
|
-
resolve( packageConfig.workingDirectory, 'jest/setup.ts' ),
|
|
37
|
-
].filter( existsSync ),
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Never ended up using this.
|
|
42
|
-
*
|
|
43
|
-
* @todo Remove in version 11.
|
|
44
|
-
*/
|
|
45
|
-
try {
|
|
46
|
-
const localConfig = require( resolve( packageConfig.workingDirectory + '/config', 'jest.config.js' ) );
|
|
47
|
-
jestConfig = {...jestConfig, ...localConfig};
|
|
48
|
-
} catch ( e ) {
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
module.exports = jestConfig;
|
package/scripts/test.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
|
|
4
|
-
const packageConfig = require( '../helpers/package-config' );
|
|
5
|
-
|
|
6
|
-
const possibleConfig = [
|
|
7
|
-
// @todo Remove pulling from the root on next major release.
|
|
8
|
-
path.resolve( packageConfig.workingDirectory + '/jest.config.js' ),
|
|
9
|
-
|
|
10
|
-
// New location.
|
|
11
|
-
path.resolve( packageConfig.workingDirectory + '/jest/jest.config.js' ),
|
|
12
|
-
path.resolve( packageConfig.workingDirectory + '/jest/jest.config.ts' ),
|
|
13
|
-
].filter( fs.existsSync );
|
|
14
|
-
|
|
15
|
-
if ( possibleConfig.length < 1 ) {
|
|
16
|
-
throw new Error( 'You must have a `jest.config.[tj]s` file in the root of your project or in the `jest` folder.' );
|
|
17
|
-
} else {
|
|
18
|
-
const file = possibleConfig.shift();
|
|
19
|
-
if ( undefined !== file ) {
|
|
20
|
-
process.argv.push( '--config', file );
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
require( 'jest-cli/bin/jest' );
|