@proteinjs/build 1.3.0 → 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.
Files changed (71) hide show
  1. package/.eslintrc.js +20 -0
  2. package/.prettierignore +4 -0
  3. package/.prettierrc +8 -0
  4. package/CHANGELOG.md +30 -178
  5. package/dist/src/Github.d.ts.map +1 -1
  6. package/dist/src/Github.js +8 -4
  7. package/dist/src/Github.js.map +1 -1
  8. package/dist/src/bin/runBuildWorkspace.js.map +1 -1
  9. package/dist/src/bin/runCleanWorkspace.js.map +1 -1
  10. package/dist/src/bin/runLintWorkspace.d.ts +3 -0
  11. package/dist/src/bin/runLintWorkspace.d.ts.map +1 -0
  12. package/dist/src/bin/runLintWorkspace.js +6 -0
  13. package/dist/src/bin/runLintWorkspace.js.map +1 -0
  14. package/dist/src/bin/runSymlinkWorkspace.js.map +1 -1
  15. package/dist/src/bin/runTestWorkspace.js.map +1 -1
  16. package/dist/src/bin/runVersionWorkspace.js.map +1 -1
  17. package/dist/src/bin/runWatchWorkspace.js.map +1 -1
  18. package/dist/src/bin/runWorkspaceCommand.js.map +1 -1
  19. package/dist/src/bin/runWorkspacePackageCommand.js.map +1 -1
  20. package/dist/src/buildWorkspace.d.ts +1 -0
  21. package/dist/src/buildWorkspace.d.ts.map +1 -1
  22. package/dist/src/buildWorkspace.js +26 -9
  23. package/dist/src/buildWorkspace.js.map +1 -1
  24. package/dist/src/cleanWorkspace.d.ts.map +1 -1
  25. package/dist/src/cleanWorkspace.js.map +1 -1
  26. package/dist/src/lintWorkspace.d.ts +9 -0
  27. package/dist/src/lintWorkspace.d.ts.map +1 -0
  28. package/dist/src/lintWorkspace.js +134 -0
  29. package/dist/src/lintWorkspace.js.map +1 -0
  30. package/dist/src/symlinkWorkspace.d.ts.map +1 -1
  31. package/dist/src/symlinkWorkspace.js +2 -1
  32. package/dist/src/symlinkWorkspace.js.map +1 -1
  33. package/dist/src/testWorkspace.d.ts.map +1 -1
  34. package/dist/src/testWorkspace.js +2 -1
  35. package/dist/src/testWorkspace.js.map +1 -1
  36. package/dist/src/versionWorkspace.d.ts.map +1 -1
  37. package/dist/src/versionWorkspace.js +99 -59
  38. package/dist/src/versionWorkspace.js.map +1 -1
  39. package/dist/src/watchWorkspace.d.ts.map +1 -1
  40. package/dist/src/watchWorkspace.js +15 -8
  41. package/dist/src/watchWorkspace.js.map +1 -1
  42. package/dist/src/workspaceCommand.d.ts.map +1 -1
  43. package/dist/src/workspaceCommand.js +4 -3
  44. package/dist/src/workspaceCommand.js.map +1 -1
  45. package/dist/src/workspacePackageCommand.d.ts.map +1 -1
  46. package/dist/src/workspacePackageCommand.js +2 -1
  47. package/dist/src/workspacePackageCommand.js.map +1 -1
  48. package/jest.config.js +8 -17
  49. package/package.json +9 -3
  50. package/src/Github.ts +30 -27
  51. package/src/bin/runBuildWorkspace.ts +2 -2
  52. package/src/bin/runCleanWorkspace.ts +2 -2
  53. package/src/bin/runLintWorkspace.ts +5 -0
  54. package/src/bin/runSymlinkWorkspace.ts +2 -2
  55. package/src/bin/runTestWorkspace.ts +2 -2
  56. package/src/bin/runVersionWorkspace.ts +2 -2
  57. package/src/bin/runWatchWorkspace.ts +2 -2
  58. package/src/bin/runWorkspaceCommand.ts +2 -2
  59. package/src/bin/runWorkspacePackageCommand.ts +2 -2
  60. package/src/buildWorkspace.ts +37 -21
  61. package/src/cleanWorkspace.ts +17 -9
  62. package/src/lintWorkspace.ts +62 -0
  63. package/src/logColors.ts +1 -1
  64. package/src/symlinkWorkspace.ts +23 -16
  65. package/src/testWorkspace.ts +19 -10
  66. package/src/versionWorkspace.ts +183 -79
  67. package/src/watchWorkspace.ts +41 -24
  68. package/src/workspaceCommand.ts +26 -20
  69. package/src/workspacePackageCommand.ts +16 -11
  70. package/tsconfig.json +18 -22
  71. package/webpack.config.js +12 -12
@@ -1,19 +1,27 @@
1
- import * as path from 'path'
2
- import { PackageUtil, cmd, WorkspaceMetadata } from '@proteinjs/util-node'
3
- import { Logger } from '@proteinjs/util'
1
+ import * as path from 'path';
2
+ import { PackageUtil, cmd, WorkspaceMetadata } from '@proteinjs/util-node';
3
+ import { Logger } from '@proteinjs/util';
4
4
 
5
5
  export const cleanWorkspace = async (workspaceMetadata?: WorkspaceMetadata) => {
6
6
  const logger = new Logger('workspace:clean');
7
7
  const workspacePath = process.cwd();
8
- const { packageMap, sortedPackageNames } = workspaceMetadata ? workspaceMetadata : await PackageUtil.getWorkspaceMetadata(workspacePath);
8
+ const { packageMap, sortedPackageNames } = workspaceMetadata
9
+ ? workspaceMetadata
10
+ : await PackageUtil.getWorkspaceMetadata(workspacePath);
9
11
  const skippedPackages = ['root'];
10
- const filteredPackageNames = sortedPackageNames.filter(packageName => !!packageMap[packageName].packageJson.scripts?.clean && !skippedPackages.includes(packageName));
12
+ const filteredPackageNames = sortedPackageNames.filter(
13
+ (packageName) => !!packageMap[packageName].packageJson.scripts?.clean && !skippedPackages.includes(packageName)
14
+ );
11
15
 
12
- logger.info(`> Cleaning ${filteredPackageNames.length} package${filteredPackageNames.length != 1 ? 's' : ''} in workspace (${workspacePath})`);
13
- for (let packageName of filteredPackageNames) {
16
+ logger.info(
17
+ `> Cleaning ${filteredPackageNames.length} package${filteredPackageNames.length != 1 ? 's' : ''} in workspace (${workspacePath})`
18
+ );
19
+ for (const packageName of filteredPackageNames) {
14
20
  const localPackage = packageMap[packageName];
15
21
  const packageDir = path.dirname(localPackage.filePath);
16
22
  await cmd('npm', ['run', 'clean'], { cwd: packageDir });
17
23
  }
18
- logger.info(`> Finished cleaning ${filteredPackageNames.length} package${filteredPackageNames.length != 1 ? 's' : ''} in workspace (${workspacePath})`);
19
- }
24
+ logger.info(
25
+ `> Finished cleaning ${filteredPackageNames.length} package${filteredPackageNames.length != 1 ? 's' : ''} in workspace (${workspacePath})`
26
+ );
27
+ };
@@ -0,0 +1,62 @@
1
+ import * as path from 'path';
2
+ import { LogColorWrapper, PackageUtil, cmd, parseArgsMap } from '@proteinjs/util-node';
3
+ import { Logger } from '@proteinjs/util';
4
+ import { primaryLogColor, secondaryLogColor } from './logColors';
5
+
6
+ /**
7
+ * Lint workspace, in dependency order.
8
+ *
9
+ * Optional args:
10
+ *
11
+ * --skip=@some/package,@another/package
12
+ */
13
+ export async function lintWorkspace() {
14
+ const cw = new LogColorWrapper();
15
+ const logger = new Logger(cw.color('workspace:', primaryLogColor) + cw.color('build', secondaryLogColor));
16
+ const args = getArgs();
17
+ const workspacePath = process.cwd();
18
+ const { packageMap, sortedPackageNames } = await PackageUtil.getWorkspaceMetadata(workspacePath);
19
+ const skippedPackages = ['root'];
20
+ const filteredPackageNames = sortedPackageNames.filter((packageName) => {
21
+ return (
22
+ !!packageMap[packageName].packageJson.scripts?.build &&
23
+ !(args.skip && args.skip.includes(packageName)) &&
24
+ !skippedPackages.includes(packageName)
25
+ );
26
+ });
27
+
28
+ logger.info(
29
+ `> Linting ${cw.color(`${filteredPackageNames.length}`, secondaryLogColor)} package${filteredPackageNames.length != 1 ? 's' : ''} in workspace (${workspacePath})`
30
+ );
31
+ logger.debug(`packageMap:\n${JSON.stringify(packageMap, null, 2)}`, true);
32
+ logger.debug(`filteredPackageNames:\n${JSON.stringify(filteredPackageNames, null, 2)}`, true);
33
+ for (const packageName of filteredPackageNames) {
34
+ const localPackage = packageMap[packageName];
35
+ const packageDir = path.dirname(localPackage.filePath);
36
+
37
+ await cmd('npx', ['prettier', '.', '--write'], { cwd: packageDir }, { logPrefix: `[${cw.color(packageName)}] ` });
38
+ await cmd('npx', ['eslint', '.', '--fix'], { cwd: packageDir }, { logPrefix: `[${cw.color(packageName)}] ` });
39
+ logger.info(`Linted ${cw.color(packageName)} (${packageDir})`);
40
+ }
41
+
42
+ logger.info(
43
+ `> Linted ${cw.color(`${filteredPackageNames.length}`, secondaryLogColor)} package${filteredPackageNames.length != 1 ? 's' : ''} in workspace (${workspacePath})`
44
+ );
45
+ }
46
+
47
+ type Args = {
48
+ skip?: string[];
49
+ };
50
+
51
+ function getArgs() {
52
+ const args: Args = {};
53
+ const argsMap = parseArgsMap(process.argv.slice(2));
54
+ for (const argName in argsMap) {
55
+ const argValue = argsMap[argName];
56
+ if (argName == 'skip' && typeof argValue === 'string') {
57
+ args.skip = argValue.split(',');
58
+ }
59
+ }
60
+
61
+ return args;
62
+ }
package/src/logColors.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export const primaryLogColor = { r: 81, g: 0, b: 135 };
2
- export const secondaryLogColor = { r: 253, g: 197, b: 0 };
2
+ export const secondaryLogColor = { r: 253, g: 197, b: 0 };
@@ -1,14 +1,14 @@
1
- import { LogColorWrapper, PackageUtil, parseArgsMap } from '@proteinjs/util-node'
2
- import { Logger } from '@proteinjs/util'
3
- import { primaryLogColor, secondaryLogColor } from './logColors'
1
+ import { LogColorWrapper, PackageUtil, parseArgsMap } from '@proteinjs/util-node';
2
+ import { Logger } from '@proteinjs/util';
3
+ import { primaryLogColor, secondaryLogColor } from './logColors';
4
4
 
5
5
  /**
6
6
  * Symlink dependencies to local packages for each package in the workspace.
7
- *
7
+ *
8
8
  * ie: `npx symlink-workspace --skip=@some/package,@another/package`
9
- *
9
+ *
10
10
  * Optional args:
11
- *
11
+ *
12
12
  * --skip=@some/package,@another/package
13
13
  */
14
14
  export const symlinkWorkspace = async () => {
@@ -18,32 +18,39 @@ export const symlinkWorkspace = async () => {
18
18
  const workspacePath = process.cwd();
19
19
  const { packageMap, sortedPackageNames } = await PackageUtil.getWorkspaceMetadata(workspacePath);
20
20
  const skippedPackages = ['root'];
21
- const filteredPackageNames = sortedPackageNames.filter(packageName => !(args.skip && args.skip.includes(packageName)) && !skippedPackages.includes(packageName));
21
+ const filteredPackageNames = sortedPackageNames.filter(
22
+ (packageName) => !(args.skip && args.skip.includes(packageName)) && !skippedPackages.includes(packageName)
23
+ );
22
24
  if (filteredPackageNames.length == 0) {
23
25
  logger.info(`> There are no packages to symlink in workspace (${workspacePath})`);
24
26
  return;
25
27
  }
26
28
 
27
- logger.info(`> Symlinking ${cw.color(`${filteredPackageNames.length}`, secondaryLogColor)} package${filteredPackageNames.length != 1 ? 's' : ''} in workspace (${workspacePath})`);
28
- for (let packageName of filteredPackageNames) {
29
+ logger.info(
30
+ `> Symlinking ${cw.color(`${filteredPackageNames.length}`, secondaryLogColor)} package${filteredPackageNames.length != 1 ? 's' : ''} in workspace (${workspacePath})`
31
+ );
32
+ for (const packageName of filteredPackageNames) {
29
33
  const localPackage = packageMap[packageName];
30
34
  await PackageUtil.symlinkDependencies(localPackage, packageMap, logger);
31
35
  }
32
- logger.info(`> Symlinked ${cw.color(`${filteredPackageNames.length}`, secondaryLogColor)} package${filteredPackageNames.length != 1 ? 's' : ''} in workspace (${workspacePath})`);
33
- }
36
+ logger.info(
37
+ `> Symlinked ${cw.color(`${filteredPackageNames.length}`, secondaryLogColor)} package${filteredPackageNames.length != 1 ? 's' : ''} in workspace (${workspacePath})`
38
+ );
39
+ };
34
40
 
35
41
  type Args = {
36
- skip?: string[],
37
- }
42
+ skip?: string[];
43
+ };
38
44
 
39
45
  function getArgs() {
40
46
  const args: Args = {};
41
47
  const argsMap = parseArgsMap(process.argv.slice(2));
42
- for (let argName in argsMap) {
48
+ for (const argName in argsMap) {
43
49
  const argValue = argsMap[argName];
44
- if (argName == 'skip' && typeof argValue === 'string')
50
+ if (argName == 'skip' && typeof argValue === 'string') {
45
51
  args.skip = argValue.split(',');
52
+ }
46
53
  }
47
54
 
48
55
  return args;
49
- }
56
+ }
@@ -1,22 +1,31 @@
1
- import * as path from 'path'
2
- import { PackageUtil, cmd, WorkspaceMetadata } from '@proteinjs/util-node'
3
- import { Logger } from '@proteinjs/util'
1
+ import * as path from 'path';
2
+ import { PackageUtil, cmd, WorkspaceMetadata } from '@proteinjs/util-node';
3
+ import { Logger } from '@proteinjs/util';
4
4
 
5
5
  export const testWorkspace = async (workspaceMetadata?: WorkspaceMetadata) => {
6
6
  const logger = new Logger('workspace:test');
7
7
  const workspacePath = process.cwd();
8
- const { packageMap, sortedPackageNames } = workspaceMetadata ? workspaceMetadata : await PackageUtil.getWorkspaceMetadata(workspacePath);
8
+ const { packageMap, sortedPackageNames } = workspaceMetadata
9
+ ? workspaceMetadata
10
+ : await PackageUtil.getWorkspaceMetadata(workspacePath);
9
11
  const skippedPackages = ['root'];
10
- const filteredPackageNames = sortedPackageNames.filter(packageName => !!packageMap[packageName].packageJson.scripts?.test && !skippedPackages.includes(packageName));
12
+ const filteredPackageNames = sortedPackageNames.filter(
13
+ (packageName) => !!packageMap[packageName].packageJson.scripts?.test && !skippedPackages.includes(packageName)
14
+ );
11
15
 
12
- logger.info(`> Testing ${filteredPackageNames.length} package${filteredPackageNames.length != 1 ? 's' : ''} in workspace (${workspacePath})`);
13
- for (let packageName of filteredPackageNames) {
16
+ logger.info(
17
+ `> Testing ${filteredPackageNames.length} package${filteredPackageNames.length != 1 ? 's' : ''} in workspace (${workspacePath})`
18
+ );
19
+ for (const packageName of filteredPackageNames) {
14
20
  const localPackage = packageMap[packageName];
15
21
  const packageDir = path.dirname(localPackage.filePath);
16
- if (!await PackageUtil.hasTests(packageDir))
22
+ if (!(await PackageUtil.hasTests(packageDir))) {
17
23
  continue;
24
+ }
18
25
 
19
26
  await cmd('npm', ['run', 'test'], { cwd: packageDir });
20
27
  }
21
- logger.info(`> Finished testing ${filteredPackageNames.length} package${filteredPackageNames.length != 1 ? 's' : ''} in workspace (${workspacePath})`);
22
- }
28
+ logger.info(
29
+ `> Finished testing ${filteredPackageNames.length} package${filteredPackageNames.length != 1 ? 's' : ''} in workspace (${workspacePath})`
30
+ );
31
+ };