@automattic/vip 2.31.1-dev → 2.31.1-dev3

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 (37) hide show
  1. package/.editorconfig +11 -0
  2. package/.prettierignore +6 -0
  3. package/CONTRIBUTING.md +20 -19
  4. package/dist/bin/vip-app-list.js +12 -10
  5. package/dist/bin/vip-dev-env-start.js +4 -1
  6. package/dist/bin/vip-dev-env-sync-sql.js +1 -1
  7. package/dist/bin/vip-export-sql.js +3 -2
  8. package/dist/bin/vip-import-media-abort.js +3 -3
  9. package/dist/bin/vip-import-media.js +3 -3
  10. package/dist/bin/vip-import-sql.js +2 -1
  11. package/dist/bin/vip-sync.js +27 -13
  12. package/dist/bin/vip-validate-preflight.js +16 -14
  13. package/dist/bin/vip-wp.js +9 -9
  14. package/dist/commands/backup-db.js +30 -26
  15. package/dist/commands/export-sql.js +2 -3
  16. package/dist/lib/api/cache-purge.js +2 -10
  17. package/dist/lib/app-logs/app-logs.js +10 -4
  18. package/dist/lib/cli/format.js +2 -2
  19. package/dist/lib/config/software.js +10 -9
  20. package/dist/lib/constants/dev-environment.js +3 -6
  21. package/dist/lib/dev-environment/dev-environment-cli.js +3 -3
  22. package/dist/lib/dev-environment/dev-environment-core.js +52 -41
  23. package/dist/lib/dev-environment/dev-environment-lando.js +3 -1
  24. package/dist/lib/envvar/api-delete.js +2 -11
  25. package/dist/lib/envvar/api-get-all.js +3 -10
  26. package/dist/lib/envvar/api-list.js +3 -10
  27. package/dist/lib/envvar/api-set.js +2 -12
  28. package/dist/lib/media-import/status.js +18 -18
  29. package/dist/lib/validations/site-type.js +1 -1
  30. package/dist/lib/validations/sql.js +2 -1
  31. package/dist/lib/vip-import-validate-files.js +1 -0
  32. package/helpers/check-version.js +7 -5
  33. package/helpers/prepublishOnly.js +90 -0
  34. package/npm-shrinkwrap.json +238 -3936
  35. package/package.json +12 -12
  36. package/tsconfig.json +5 -9
  37. package/automattic-vip-2.31.1-dev.tgz +0 -0
@@ -0,0 +1,90 @@
1
+ const util = require( 'node:util' );
2
+ const check = util.promisify( require( 'check-node-version' ) );
3
+ const { exec } = require( 'node:child_process' );
4
+ const { EOL } = require( 'node:os' );
5
+ const packageJSON = require( '../package.json' );
6
+
7
+ const config = {
8
+ gitAllowDirty: true,
9
+ gitEnforceBranch: 'trunk',
10
+ nodeEnforceVersion: packageJSON.engines.node,
11
+ testBeforePublish: true,
12
+ };
13
+
14
+ const releaseTag = process.env.npm_config_tag ?? 'latest';
15
+
16
+ ( async () => {
17
+ try {
18
+ if ( ! config.gitAllowDirty ) {
19
+ const status = await execAsync( 'git status --porcelain' );
20
+
21
+ if ( status.split( EOL ).length > 0 ) {
22
+ return bail( 'Git working directory is dirty. Please commit changes before publishing.' );
23
+ }
24
+ }
25
+
26
+ if ( config.gitEnforceBranch && releaseTag !== 'next' ) {
27
+ const currentBranch = await execAsync( 'git branch --show-current' );
28
+
29
+ if ( currentBranch.trim() !== config.gitEnforceBranch ) {
30
+ return bail(
31
+ `Git branch is not ${ config.gitEnforceBranch }. Please switch to ${ config.gitEnforceBranch } before publishing.`
32
+ );
33
+ }
34
+ }
35
+
36
+ if ( config.nodeEnforceVersion ) {
37
+ const { isSatisfied, versions } = await check( { node: config.nodeEnforceVersion } );
38
+
39
+ if ( ! isSatisfied ) {
40
+ return bail(
41
+ `Node version ${ versions.node.version } is not supported. Please use Node version ${ config.nodeEnforceVersion } or higher.`
42
+ );
43
+ }
44
+ }
45
+
46
+ if ( config.testBeforePublish ) {
47
+ console.log( 'Running tests before publishing...' );
48
+
49
+ await execAsync( 'npm test', true );
50
+ }
51
+
52
+ process.exit( 0 );
53
+ } catch ( error ) {
54
+ bail( error );
55
+ }
56
+ } )();
57
+
58
+ async function execAsync( command, pipe = false ) {
59
+ const handle = exec( command );
60
+ const stdout = [];
61
+ const stderr = [];
62
+
63
+ handle.stdout.on( 'data', data => {
64
+ stdout.push( data.toString() );
65
+ } );
66
+
67
+ handle.stderr.on( 'data', data => {
68
+ stderr.push( data.toString() );
69
+ } );
70
+
71
+ if ( pipe ) {
72
+ handle.stdout.pipe( process.stdout );
73
+ handle.stderr.pipe( process.stderr );
74
+ }
75
+
76
+ return new Promise( ( resolve, reject ) => {
77
+ handle.on( 'close', code => {
78
+ if ( code === 0 ) {
79
+ resolve( stdout.join( '' ) );
80
+ } else {
81
+ reject( stderr.join( '' ) );
82
+ }
83
+ } );
84
+ } );
85
+ }
86
+
87
+ function bail( message ) {
88
+ console.error( message );
89
+ process.exit( 1 );
90
+ }