@proteinjs/build 1.3.1 → 1.4.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/.eslintrc.js +20 -0
- package/.prettierignore +4 -0
- package/.prettierrc +8 -0
- package/CHANGELOG.md +29 -188
- package/dist/src/Github.d.ts.map +1 -1
- package/dist/src/Github.js +8 -4
- package/dist/src/Github.js.map +1 -1
- package/dist/src/bin/runBuildWorkspace.js.map +1 -1
- package/dist/src/bin/runCleanWorkspace.js.map +1 -1
- package/dist/src/bin/runLintWorkspace.d.ts +3 -0
- package/dist/src/bin/runLintWorkspace.d.ts.map +1 -0
- package/dist/src/bin/runLintWorkspace.js +6 -0
- package/dist/src/bin/runLintWorkspace.js.map +1 -0
- package/dist/src/bin/runSymlinkWorkspace.js.map +1 -1
- package/dist/src/bin/runTestWorkspace.js.map +1 -1
- package/dist/src/bin/runVersionWorkspace.js.map +1 -1
- package/dist/src/bin/runWatchWorkspace.js.map +1 -1
- package/dist/src/bin/runWorkspaceCommand.js.map +1 -1
- package/dist/src/bin/runWorkspacePackageCommand.js.map +1 -1
- package/dist/src/buildWorkspace.d.ts +1 -0
- package/dist/src/buildWorkspace.d.ts.map +1 -1
- package/dist/src/buildWorkspace.js +26 -9
- package/dist/src/buildWorkspace.js.map +1 -1
- package/dist/src/cleanWorkspace.d.ts.map +1 -1
- package/dist/src/cleanWorkspace.js.map +1 -1
- package/dist/src/lintWorkspace.d.ts +9 -0
- package/dist/src/lintWorkspace.d.ts.map +1 -0
- package/dist/src/lintWorkspace.js +134 -0
- package/dist/src/lintWorkspace.js.map +1 -0
- package/dist/src/symlinkWorkspace.d.ts.map +1 -1
- package/dist/src/symlinkWorkspace.js +2 -1
- package/dist/src/symlinkWorkspace.js.map +1 -1
- package/dist/src/testWorkspace.d.ts.map +1 -1
- package/dist/src/testWorkspace.js +2 -1
- package/dist/src/testWorkspace.js.map +1 -1
- package/dist/src/versionWorkspace.d.ts.map +1 -1
- package/dist/src/versionWorkspace.js +59 -31
- package/dist/src/versionWorkspace.js.map +1 -1
- package/dist/src/watchWorkspace.d.ts.map +1 -1
- package/dist/src/watchWorkspace.js +15 -8
- package/dist/src/watchWorkspace.js.map +1 -1
- package/dist/src/workspaceCommand.d.ts.map +1 -1
- package/dist/src/workspaceCommand.js +4 -3
- package/dist/src/workspaceCommand.js.map +1 -1
- package/dist/src/workspacePackageCommand.d.ts.map +1 -1
- package/dist/src/workspacePackageCommand.js +2 -1
- package/dist/src/workspacePackageCommand.js.map +1 -1
- package/jest.config.js +8 -17
- package/package.json +9 -3
- package/src/Github.ts +30 -27
- package/src/bin/runBuildWorkspace.ts +2 -2
- package/src/bin/runCleanWorkspace.ts +2 -2
- package/src/bin/runLintWorkspace.ts +5 -0
- package/src/bin/runSymlinkWorkspace.ts +2 -2
- package/src/bin/runTestWorkspace.ts +2 -2
- package/src/bin/runVersionWorkspace.ts +2 -2
- package/src/bin/runWatchWorkspace.ts +2 -2
- package/src/bin/runWorkspaceCommand.ts +2 -2
- package/src/bin/runWorkspacePackageCommand.ts +2 -2
- package/src/buildWorkspace.ts +37 -21
- package/src/cleanWorkspace.ts +17 -9
- package/src/lintWorkspace.ts +62 -0
- package/src/logColors.ts +1 -1
- package/src/symlinkWorkspace.ts +23 -16
- package/src/testWorkspace.ts +19 -10
- package/src/versionWorkspace.ts +173 -79
- package/src/watchWorkspace.ts +41 -24
- package/src/workspaceCommand.ts +26 -20
- package/src/workspacePackageCommand.ts +16 -11
- package/tsconfig.json +18 -22
- package/webpack.config.js +12 -12
package/src/watchWorkspace.ts
CHANGED
|
@@ -1,35 +1,45 @@
|
|
|
1
|
-
import * as path from 'path'
|
|
2
|
-
import { PackageUtil, WorkspaceMetadata, cmd, LogColorWrapper } from '@proteinjs/util-node'
|
|
3
|
-
import { Logger } from '@proteinjs/util'
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { PackageUtil, WorkspaceMetadata, cmd, LogColorWrapper } from '@proteinjs/util-node';
|
|
3
|
+
import { Logger } from '@proteinjs/util';
|
|
4
4
|
import { primaryLogColor, secondaryLogColor } from './logColors';
|
|
5
5
|
|
|
6
6
|
export const watchWorkspace = async (workspaceMetadata?: WorkspaceMetadata) => {
|
|
7
7
|
const cw = new LogColorWrapper();
|
|
8
8
|
const logger = new Logger(cw.color('workspace:', primaryLogColor) + cw.color('watch', secondaryLogColor));
|
|
9
9
|
const workspacePath = process.cwd();
|
|
10
|
-
const { packageMap, sortedPackageNames } = workspaceMetadata
|
|
10
|
+
const { packageMap, sortedPackageNames } = workspaceMetadata
|
|
11
|
+
? workspaceMetadata
|
|
12
|
+
: await PackageUtil.getWorkspaceMetadata(workspacePath);
|
|
11
13
|
const skippedPackages = ['root'];
|
|
12
|
-
const filteredPackageNames = sortedPackageNames.filter(
|
|
14
|
+
const filteredPackageNames = sortedPackageNames.filter(
|
|
15
|
+
(packageName) => !!packageMap[packageName].packageJson.scripts?.watch && !skippedPackages.includes(packageName)
|
|
16
|
+
);
|
|
13
17
|
|
|
14
|
-
logger.info(
|
|
18
|
+
logger.info(
|
|
19
|
+
`> Watching ${cw.color(`${filteredPackageNames.length}`, secondaryLogColor)} package${filteredPackageNames.length != 1 ? 's' : ''} in workspace (${workspacePath})`
|
|
20
|
+
);
|
|
15
21
|
const loggingStartDelay = 0;
|
|
16
|
-
for (
|
|
22
|
+
for (const packageName of filteredPackageNames) {
|
|
17
23
|
const localPackage = packageMap[packageName];
|
|
18
24
|
const packageDir = path.dirname(localPackage.filePath);
|
|
19
25
|
const loggingEnabledState = { loggingEnabled: false };
|
|
20
|
-
setTimeout(() => loggingEnabledState.loggingEnabled = true, loggingStartDelay);
|
|
26
|
+
setTimeout(() => (loggingEnabledState.loggingEnabled = true), loggingStartDelay);
|
|
21
27
|
const logPrefix = `[${cw.color(packageName)}] `;
|
|
22
28
|
let inMultiLineLog = false;
|
|
23
29
|
const stdoutFilter = (log: string) => {
|
|
24
|
-
if (log.includes('File change detected. Starting incremental compilation'))
|
|
30
|
+
if (log.includes('File change detected. Starting incremental compilation')) {
|
|
25
31
|
return;
|
|
26
|
-
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// eslint-disable-next-line no-control-regex
|
|
27
35
|
let filteredOutput = log.replace(/\x1Bc|\x1B\[2J\x1B\[0;0H/g, ''); // char sequence for clearing terminal
|
|
28
|
-
if (filteredOutput.includes('Watching for file changes.'))
|
|
36
|
+
if (filteredOutput.includes('Watching for file changes.')) {
|
|
29
37
|
filteredOutput = filteredOutput.replace(/^\n/, '');
|
|
38
|
+
}
|
|
30
39
|
|
|
31
|
-
if (filteredOutput.trim() == '')
|
|
40
|
+
if (filteredOutput.trim() == '') {
|
|
32
41
|
return;
|
|
42
|
+
}
|
|
33
43
|
|
|
34
44
|
// Replace newline with newline+prefix under the following conditions:
|
|
35
45
|
// 1. It is not at the start of the string (?<!^)
|
|
@@ -37,22 +47,29 @@ export const watchWorkspace = async (workspaceMetadata?: WorkspaceMetadata) => {
|
|
|
37
47
|
// 3. It is not followed by another newline (?!\r?\n)
|
|
38
48
|
filteredOutput = filteredOutput.replace(/(?<!^)(\r?\n)(?!\r?\n|$)/g, `$1${logPrefix}`);
|
|
39
49
|
|
|
40
|
-
if (!inMultiLineLog)
|
|
50
|
+
if (!inMultiLineLog) {
|
|
41
51
|
filteredOutput = `${logPrefix}${filteredOutput}`;
|
|
52
|
+
}
|
|
42
53
|
|
|
43
|
-
if (filteredOutput.endsWith('\n') || filteredOutput.endsWith('\r\n'))
|
|
54
|
+
if (filteredOutput.endsWith('\n') || filteredOutput.endsWith('\r\n')) {
|
|
44
55
|
inMultiLineLog = false;
|
|
45
|
-
else
|
|
56
|
+
} else {
|
|
46
57
|
inMultiLineLog = true;
|
|
47
|
-
|
|
58
|
+
}
|
|
59
|
+
|
|
48
60
|
return filteredOutput;
|
|
49
61
|
};
|
|
50
|
-
cmd(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
cmd(
|
|
63
|
+
'npm',
|
|
64
|
+
['run', 'watch'],
|
|
65
|
+
{ cwd: packageDir },
|
|
66
|
+
{
|
|
67
|
+
omitLogs: {
|
|
68
|
+
stdout: {
|
|
69
|
+
filter: stdoutFilter,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
);
|
|
57
74
|
}
|
|
58
|
-
}
|
|
75
|
+
};
|
package/src/workspaceCommand.ts
CHANGED
|
@@ -1,56 +1,62 @@
|
|
|
1
|
-
import * as path from 'path'
|
|
2
|
-
import { LocalPackageMap, LogColorWrapper, PackageUtil, cmd, parseArgsMap } from '@proteinjs/util-node'
|
|
3
|
-
import { Logger } from '@proteinjs/util'
|
|
4
|
-
import { primaryLogColor, secondaryLogColor } from './logColors'
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { LocalPackageMap, LogColorWrapper, PackageUtil, cmd, parseArgsMap } from '@proteinjs/util-node';
|
|
3
|
+
import { Logger } from '@proteinjs/util';
|
|
4
|
+
import { primaryLogColor, secondaryLogColor } from './logColors';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Run a npm command against all packages in the workspace, in dependency order.
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
* ie: `npx workspace test --skip=@some/package,@another/package`
|
|
10
|
-
*
|
|
10
|
+
*
|
|
11
11
|
* Optional args:
|
|
12
|
-
*
|
|
12
|
+
*
|
|
13
13
|
* --skip=@some/package,@another/package
|
|
14
14
|
*/
|
|
15
15
|
export const workspaceCommand = async () => {
|
|
16
|
-
const command = process.argv[2]
|
|
16
|
+
const command = process.argv[2];
|
|
17
17
|
const cw = new LogColorWrapper();
|
|
18
18
|
const logger = new Logger(cw.color('workspace:', primaryLogColor) + cw.color(command, secondaryLogColor));
|
|
19
19
|
const args = getArgs();
|
|
20
20
|
const workspacePath = process.cwd();
|
|
21
21
|
const { packageMap, sortedPackageNames } = await PackageUtil.getWorkspaceMetadata(workspacePath);
|
|
22
22
|
const skippedPackages = ['root'];
|
|
23
|
-
const filteredPackageNames = sortedPackageNames.filter(packageName => {
|
|
24
|
-
return
|
|
23
|
+
const filteredPackageNames = sortedPackageNames.filter((packageName) => {
|
|
24
|
+
return (
|
|
25
|
+
hasScript(command, packageName, packageMap) &&
|
|
25
26
|
!(args.skip && args.skip.includes(packageName)) &&
|
|
26
27
|
!skippedPackages.includes(packageName)
|
|
27
|
-
;
|
|
28
|
+
);
|
|
28
29
|
});
|
|
29
30
|
if (filteredPackageNames.length == 0) {
|
|
30
31
|
logger.info(`> There are no packages with the \`${command}\` script in workspace (${workspacePath})`);
|
|
31
32
|
return;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
logger.info(
|
|
35
|
-
|
|
35
|
+
logger.info(
|
|
36
|
+
`> Running \`npm run ${command}\` for ${cw.color(`${filteredPackageNames.length}`, secondaryLogColor)} package${filteredPackageNames.length != 1 ? 's' : ''} in workspace (${workspacePath})`
|
|
37
|
+
);
|
|
38
|
+
for (const packageName of filteredPackageNames) {
|
|
36
39
|
const localPackage = packageMap[packageName];
|
|
37
40
|
const packageDir = path.dirname(localPackage.filePath);
|
|
38
41
|
await cmd('npm', ['run', command], { cwd: packageDir }, { logPrefix: `[${cw.color(packageName)}] ` });
|
|
39
42
|
}
|
|
40
|
-
logger.info(
|
|
41
|
-
}
|
|
43
|
+
logger.info(
|
|
44
|
+
`> Ran \`npm run ${command}\` for ${cw.color(`${filteredPackageNames.length}`, secondaryLogColor)} package${filteredPackageNames.length != 1 ? 's' : ''} in workspace (${workspacePath})`
|
|
45
|
+
);
|
|
46
|
+
};
|
|
42
47
|
|
|
43
48
|
type Args = {
|
|
44
|
-
skip?: string[]
|
|
45
|
-
}
|
|
49
|
+
skip?: string[];
|
|
50
|
+
};
|
|
46
51
|
|
|
47
52
|
function getArgs() {
|
|
48
53
|
const args: Args = {};
|
|
49
54
|
const argsMap = parseArgsMap(process.argv.slice(3));
|
|
50
|
-
for (
|
|
55
|
+
for (const argName in argsMap) {
|
|
51
56
|
const argValue = argsMap[argName];
|
|
52
|
-
if (argName == 'skip' && typeof argValue === 'string')
|
|
57
|
+
if (argName == 'skip' && typeof argValue === 'string') {
|
|
53
58
|
args.skip = argValue.split(',');
|
|
59
|
+
}
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
return args;
|
|
@@ -58,4 +64,4 @@ function getArgs() {
|
|
|
58
64
|
|
|
59
65
|
function hasScript(scriptName: string, packageName: string, packageMap: LocalPackageMap) {
|
|
60
66
|
return !!packageMap[packageName].packageJson.scripts && !!packageMap[packageName].packageJson.scripts[scriptName];
|
|
61
|
-
}
|
|
67
|
+
}
|
|
@@ -1,26 +1,31 @@
|
|
|
1
|
-
import * as path from 'path'
|
|
2
|
-
import { LogColorWrapper, PackageUtil, cmd } from '@proteinjs/util-node'
|
|
3
|
-
import { Logger } from '@proteinjs/util'
|
|
4
|
-
import { primaryLogColor, secondaryLogColor } from './logColors'
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { LogColorWrapper, PackageUtil, cmd } from '@proteinjs/util-node';
|
|
3
|
+
import { Logger } from '@proteinjs/util';
|
|
4
|
+
import { primaryLogColor, secondaryLogColor } from './logColors';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Run a command in the directory of the specified package.
|
|
8
8
|
* If running an npm command, this utility re-symlinks dependencies afterwards.
|
|
9
|
-
*
|
|
9
|
+
*
|
|
10
10
|
* ie: `npx workspace-package @my/package npm i react`
|
|
11
11
|
*/
|
|
12
12
|
export const workspacePackageCommand = async () => {
|
|
13
|
-
const packageName = process.argv[2]
|
|
13
|
+
const packageName = process.argv[2];
|
|
14
14
|
const command = process.argv[3];
|
|
15
15
|
const args = process.argv.slice(4);
|
|
16
16
|
const cw = new LogColorWrapper();
|
|
17
|
-
const logger = new Logger(
|
|
17
|
+
const logger = new Logger(
|
|
18
|
+
`${cw.color('workspace-package(', primaryLogColor)}${cw.color(packageName, secondaryLogColor)}${cw.color(')', primaryLogColor)}`
|
|
19
|
+
);
|
|
18
20
|
const workspacePath = process.cwd();
|
|
19
21
|
const { packageMap } = await PackageUtil.getWorkspaceMetadata(workspacePath);
|
|
20
22
|
const localPackage = packageMap[packageName];
|
|
21
|
-
if (!localPackage)
|
|
22
|
-
throw new Error(
|
|
23
|
-
|
|
23
|
+
if (!localPackage) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
`Package (${cw.color(packageName, secondaryLogColor)}) does not exist in workspace: ${workspacePath}`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
24
29
|
const packageDir = path.dirname(localPackage.filePath);
|
|
25
30
|
logger.info(`Running command: ${cw.color(`${command} ${args.join(' ')}`, secondaryLogColor)}`);
|
|
26
31
|
await cmd(command, args, { cwd: packageDir }, { logPrefix: `[${cw.color(packageName, secondaryLogColor)}] ` });
|
|
@@ -32,4 +37,4 @@ export const workspacePackageCommand = async () => {
|
|
|
32
37
|
await PackageUtil.symlinkDependencies(localPackage, packageMap, logger);
|
|
33
38
|
logger.info(`Symlinked local dependencies`);
|
|
34
39
|
}
|
|
35
|
-
}
|
|
40
|
+
};
|
package/tsconfig.json
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"node", "jest"
|
|
21
|
-
]
|
|
22
|
-
}
|
|
23
|
-
}
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"rootDir": "./",
|
|
4
|
+
"target": "es5",
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": true,
|
|
8
|
+
"sourceMap": true,
|
|
9
|
+
"outDir": "./dist/",
|
|
10
|
+
"strict": true,
|
|
11
|
+
"noImplicitAny": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
"typeRoots": ["./node_modules/@types"],
|
|
17
|
+
"types": ["node", "jest"]
|
|
18
|
+
}
|
|
19
|
+
}
|
package/webpack.config.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
target: 'node',
|
|
3
|
-
entry: './dist/src/runBuildWorkspace.js',
|
|
2
|
+
target: 'node', // Ensures that webpack emulates Node.js environment
|
|
3
|
+
entry: './dist/src/runBuildWorkspace.js', // Entry point of your application
|
|
4
4
|
output: {
|
|
5
|
-
path: __dirname,
|
|
6
|
-
filename: 'build-workspace.js'
|
|
5
|
+
path: __dirname, // Output directory
|
|
6
|
+
filename: 'build-workspace.js', // Output file
|
|
7
7
|
},
|
|
8
8
|
module: {
|
|
9
9
|
rules: [
|
|
10
10
|
{
|
|
11
|
-
test: /\.js$/,
|
|
12
|
-
exclude: /node_modules/,
|
|
11
|
+
test: /\.js$/, // Include .js files
|
|
12
|
+
exclude: /node_modules/, // Exclude node_modules from babel-loader
|
|
13
13
|
use: {
|
|
14
|
-
loader: 'babel-loader',
|
|
14
|
+
loader: 'babel-loader', // Use babel-loader for transpiling
|
|
15
15
|
options: {
|
|
16
|
-
presets: ['@babel/preset-env']
|
|
17
|
-
}
|
|
18
|
-
}
|
|
16
|
+
presets: ['@babel/preset-env'],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
19
|
},
|
|
20
20
|
// Add more rules for other file types if needed
|
|
21
|
-
]
|
|
21
|
+
],
|
|
22
22
|
},
|
|
23
23
|
resolve: {
|
|
24
|
-
extensions: ['.js'],
|
|
24
|
+
extensions: ['.js'], // File extensions to process
|
|
25
25
|
},
|
|
26
26
|
};
|