Monorepo Utils: Migrate cli-core (#38018)

* move source files

* add uuid type dependency
This commit is contained in:
Paul Sealock 2023-04-28 10:16:19 +12:00 committed by GitHub
parent 6b158648e3
commit ce7733ae78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 636 additions and 659 deletions

View File

@ -22,7 +22,7 @@ jobs:
run: |
npm install -g pnpm
npm -g i @wordpress/env@5.1.0
pnpm install --filter code-analyzer --filter cli-core
pnpm install --filter code-analyzer --filter monorepo-utils
- name: Run analyzer
id: run
working-directory: tools/code-analyzer

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,6 @@ packages:
- 'tools/package-release'
- 'tools/cherry-pick'
- 'tools/release-posts'
- 'tools/cli-core'
- 'tools/version-bump'
- 'tools/storybook'
- 'tools/monorepo-utils'

View File

@ -1,4 +0,0 @@
### CLI Core
This package contains utilities and libraries providing core functionality to
cli tools within `tools` so that this functionality can be easily reused.

View File

@ -1,25 +0,0 @@
{
"name": "cli-core",
"version": "0.0.1",
"description": "Core functionality for CLI tools/commands.",
"main": " ",
"author": "Automattic",
"license": "GPL-2.0-or-later",
"engines": {
"node": "^16.13.1",
"pnpm": "^8.3.1"
},
"devDependencies": {
"@tsconfig/node16": "^1.0.3",
"@types/uuid": "^9.0.0",
"typescript": "^4.9.5"
},
"dependencies": {
"chalk": "^4.1.2",
"dotenv": "^10.0.0",
"ora": "^5.4.1",
"simple-git": "^3.10.0",
"ts-node": "^10.9.1",
"uuid": "^8.3.2"
}
}

View File

@ -1,7 +0,0 @@
{
"extends": "@tsconfig/node16/tsconfig.json",
"ts-node": {
"transpileOnly": true,
"files": true,
}
}

View File

@ -9,10 +9,10 @@
"dependencies": {
"@actions/core": "^1.10.0",
"@commander-js/extra-typings": "^0.1.0",
"@woocommerce/monorepo-utils": "workspace:*",
"@oclif/core": "^2.4.0",
"@tsconfig/node16": "^1.0.3",
"@types/uuid": "^8.3.4",
"cli-core": "workspace:*",
"commander": "^9.4.0",
"dotenv": "^10.0.0",
"simple-git": "^3.10.0",

View File

@ -2,7 +2,7 @@
* External dependencies
*/
import { Command } from '@commander-js/extra-typings';
import { Logger } from 'cli-core/src/logger';
import { Logger } from '@woocommerce/monorepo-utils/src/core/logger';
import { join } from 'path';
/**

View File

@ -4,8 +4,8 @@
import { join } from 'path';
import { readFile } from 'fs/promises';
import simpleGit from 'simple-git';
import { cloneRepo } from 'cli-core/src/git';
import { Logger } from 'cli-core/src/logger';
import { cloneRepo } from '@woocommerce/monorepo-utils/src/core/git';
import { Logger } from '@woocommerce/monorepo-utils/src/core/logger';
import { Command } from '@commander-js/extra-typings';
/**

View File

@ -2,7 +2,7 @@
* External dependencies
*/
import { Command } from '@commander-js/extra-typings';
import { Logger } from 'cli-core/src/logger';
import { Logger } from '@woocommerce/monorepo-utils/src/core/logger';
import { join } from 'path';
/**

View File

@ -3,7 +3,11 @@
*/
import { join } from 'path';
import { simpleGit } from 'simple-git';
import { execAsync, startWPEnv, stopWPEnv } from 'cli-core/src/util';
import { execAsync } from '@woocommerce/monorepo-utils/src/core/util';
import {
startWPEnv,
stopWPEnv,
} from '@woocommerce/monorepo-utils/src/core/wpenv';
export type SchemaDump = {
schema: string;

View File

@ -1,7 +1,10 @@
/**
* External dependencies
*/
import { getFilename, getPatches } from 'cli-core/src/git';
import {
getFilename,
getPatches,
} from '@woocommerce/monorepo-utils/src/core/git';
export const scanForDBChanges = ( content: string ) => {
const matchPatches = /^a\/(.+).php/g;

View File

@ -1,7 +1,10 @@
/**
* External dependencies
*/
import { getFilename, getPatches } from 'cli-core/src/util';
import {
getFilename,
getPatches,
} from '@woocommerce/monorepo-utils/src/core/git';
import fs from 'node:fs';
/**

View File

@ -1,9 +1,12 @@
/**
* External dependencies
*/
import { Logger } from 'cli-core/src/logger';
import { Logger } from '@woocommerce/monorepo-utils/src/core/logger';
import { join } from 'path';
import { cloneRepo, generateDiff } from 'cli-core/src/git';
import {
cloneRepo,
generateDiff,
} from '@woocommerce/monorepo-utils/src/core/git';
import { readFile } from 'fs/promises';
import { execSync } from 'child_process';

View File

@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { Logger } from 'cli-core/src/logger';
import { Logger } from '@woocommerce/monorepo-utils/src/core/logger';
import { readFile } from 'fs/promises';
import { join } from 'path';

View File

@ -7,8 +7,8 @@ import {
getPullRequestNumberFromHash,
getPatches,
getLineCommitHash,
} from 'cli-core/src/git';
import { Logger } from 'cli-core/src/logger';
} from '@woocommerce/monorepo-utils/src/core/git';
import { Logger } from '@woocommerce/monorepo-utils/src/core/logger';
export type TemplateChangeDescription = {
filePath: string;

View File

@ -12,6 +12,7 @@
"@commander-js/extra-typings": "^0.1.0",
"@octokit/graphql": "4.8.0",
"@octokit/graphql-schema": "^14.1.0",
"@types/uuid": "^9.0.1",
"chalk": "^4.1.2",
"commander": "^9.4.0",
"dotenv": "^10.0.0",
@ -20,7 +21,9 @@
"octokit": "^2.0.14",
"ora": "^5.4.1",
"promptly": "^3.2.0",
"semver": "^7.3.2"
"semver": "^7.3.2",
"simple-git": "^3.10.0",
"uuid": "^9.0.0"
},
"devDependencies": {
"@types/jest": "^27.4.1",

View File

@ -12,17 +12,18 @@ import { setOutput } from '@actions/core';
* Internal dependencies
*/
import {
getLatestReleaseVersion,
getLatestGithubReleaseVersion,
doesGithubBranchExist,
getRefFromGithubBranch,
createGithubBranch,
deleteGithubBranch,
} from '../../../github/repo';
import { WPIncrement } from '../milestone/utils';
} from '../../../core/github/repo';
import { WPIncrement } from '../../../core/version';
import { Logger } from '../../../core/logger';
import { Options } from './types';
const getNextReleaseBranch = async ( options: Options ) => {
const latestReleaseVersion = await getLatestReleaseVersion( options );
const latestReleaseVersion = await getLatestGithubReleaseVersion( options );
const nextReleaseVersion = WPIncrement( latestReleaseVersion );
const parsedNextReleaseVersion = parse( nextReleaseVersion );
const nextReleaseMajorMinor = `${ parsedNextReleaseVersion.major }.${ parsedNextReleaseVersion.minor }`;
@ -66,11 +67,7 @@ export const branchCommand = new Command( 'branch' )
)
).start();
nextReleaseBranch = await getNextReleaseBranch( options );
console.log(
chalk.yellow(
`The next release branch is ${ nextReleaseBranch }`
)
);
Logger.warn( `The next release branch is ${ nextReleaseBranch }` );
versionSpinner.succeed();
} else {
nextReleaseBranch = branch;
@ -90,10 +87,8 @@ export const branchCommand = new Command( 'branch' )
if ( branchExists ) {
if ( github ) {
console.log(
chalk.red(
`Release branch ${ nextReleaseBranch } already exists`
)
Logger.error(
`Release branch ${ nextReleaseBranch } already exists`
);
// When in Github Actions, we don't want to prompt the user for input.
process.exit( 0 );
@ -104,18 +99,18 @@ export const branchCommand = new Command( 'branch' )
)
);
if ( deleteExistingReleaseBranch ) {
const deleteBranchSpinner = ora(
chalk.yellow(
`Delete branch ${ nextReleaseBranch } on ${ owner }/${ name } and create new one from ${ source }`
)
).start();
await deleteGithubBranch( options, nextReleaseBranch );
deleteBranchSpinner.succeed();
if ( ! dryRun ) {
const deleteBranchSpinner = ora(
chalk.yellow(
`Delete branch ${ nextReleaseBranch } on ${ owner }/${ name } and create new one from ${ source }`
)
).start();
await deleteGithubBranch( options, nextReleaseBranch );
deleteBranchSpinner.succeed();
}
} else {
console.log(
chalk.green(
`Branch ${ nextReleaseBranch } already exist on ${ owner }/${ name }, no action taken.`
)
Logger.notice(
`Branch ${ nextReleaseBranch } already exist on ${ owner }/${ name }, no action taken.`
);
process.exit( 0 );
}
@ -127,10 +122,8 @@ export const branchCommand = new Command( 'branch' )
if ( dryRun ) {
createBranchSpinner.succeed();
console.log(
chalk.green(
`DRY RUN: Skipping actual creation of branch ${ nextReleaseBranch } on ${ owner }/${ name }`
)
Logger.notice(
`DRY RUN: Skipping actual creation of branch ${ nextReleaseBranch } on ${ owner }/${ name }`
);
process.exit( 0 );
@ -144,9 +137,7 @@ export const branchCommand = new Command( 'branch' )
setOutput( 'nextReleaseBranch', nextReleaseBranch );
}
console.log(
chalk.green(
`Branch ${ nextReleaseBranch } successfully created on ${ owner }/${ name }`
)
Logger.notice(
`Branch ${ nextReleaseBranch } successfully created on ${ owner }/${ name }`
);
} );

View File

@ -2,16 +2,17 @@
* External dependencies
*/
import { Command } from '@commander-js/extra-typings';
import chalk from 'chalk';
import ora from 'ora';
/**
* Internal dependencies
*/
import { getLatestReleaseVersion } from '../../../github/repo';
import { octokitWithAuth } from '../../../github/api';
import { setGithubMilestoneOutputs, WPIncrement } from './utils';
import { getLatestGithubReleaseVersion } from '../../../core/github/repo';
import { octokitWithAuth } from '../../../core/github/api';
import { setGithubMilestoneOutputs } from './utils';
import { WPIncrement } from '../../../core/version';
import { Options } from './types';
import { Logger } from '../../../core/logger';
export const milestoneCommand = new Command( 'milestone' )
.description( 'Create a milestone' )
@ -38,10 +39,8 @@ export const milestoneCommand = new Command( 'milestone' )
const { owner, name, dryRun, milestone, github } = options;
if ( milestone && github ) {
console.log(
chalk.red(
"You can't manually supply a milestone using Github mode. Please use the CLI locally to add a milestone."
)
Logger.error(
"You can't manually supply a milestone using Github mode. Please use the CLI locally to add a milestone."
);
process.exit( 1 );
}
@ -50,17 +49,15 @@ export const milestoneCommand = new Command( 'milestone' )
let nextReleaseVersion;
if ( milestone ) {
console.log(
chalk.yellow(
`Manually creating milestone ${ milestone } in ${ owner }/${ name }`
)
Logger.warn(
`Manually creating milestone ${ milestone } in ${ owner }/${ name }`
);
nextMilestone = milestone;
} else {
const versionSpinner = ora(
'No milestone supplied, going off the latest release version'
).start();
const latestReleaseVersion = await getLatestReleaseVersion(
const latestReleaseVersion = await getLatestGithubReleaseVersion(
options
);
versionSpinner.succeed();
@ -68,22 +65,16 @@ export const milestoneCommand = new Command( 'milestone' )
nextReleaseVersion = WPIncrement( latestReleaseVersion );
nextMilestone = WPIncrement( nextReleaseVersion );
console.log(
chalk.yellow(
`The latest release in ${ owner }/${ name } is version: ${ latestReleaseVersion }`
)
Logger.warn(
`The latest release in ${ owner }/${ name } is version: ${ latestReleaseVersion }`
);
console.log(
chalk.yellow(
`The next release in ${ owner }/${ name } will be version: ${ nextReleaseVersion }`
)
Logger.warn(
`The next release in ${ owner }/${ name } will be version: ${ nextReleaseVersion }`
);
console.log(
chalk.yellow(
`The next milestone in ${ owner }/${ name } will be: ${ nextMilestone }`
)
Logger.warn(
`The next milestone in ${ owner }/${ name } will be: ${ nextMilestone }`
);
}
@ -93,10 +84,8 @@ export const milestoneCommand = new Command( 'milestone' )
if ( dryRun ) {
milestoneSpinner.succeed();
console.log(
chalk.green(
`DRY RUN: Skipping actual creation of milestone ${ nextMilestone }`
)
Logger.notice(
`DRY RUN: Skipping actual creation of milestone ${ nextMilestone }`
);
process.exit( 0 );
@ -116,10 +105,8 @@ export const milestoneCommand = new Command( 'milestone' )
if ( milestoneAlreadyExistsError ) {
milestoneSpinner.succeed();
console.log(
chalk.green(
`Milestone ${ nextMilestone } already exists in ${ owner }/${ name }`
)
Logger.notice(
`Milestone ${ nextMilestone } already exists in ${ owner }/${ name }`
);
if ( github ) {
setGithubMilestoneOutputs(
@ -130,12 +117,10 @@ export const milestoneCommand = new Command( 'milestone' )
process.exit( 0 );
} else {
milestoneSpinner.fail();
console.log(
chalk.red(
`\nFailed to create milestone ${ nextMilestone } in ${ owner }/${ name }`
)
Logger.error(
`\nFailed to create milestone ${ nextMilestone } in ${ owner }/${ name }`
);
console.log( chalk.red( e.response.data.message ) );
Logger.error( e.response.data.message );
process.exit( 1 );
}
}
@ -144,9 +129,7 @@ export const milestoneCommand = new Command( 'milestone' )
if ( github ) {
setGithubMilestoneOutputs( nextReleaseVersion, nextMilestone );
}
console.log(
chalk.green(
`Successfully created milestone ${ nextMilestone } in ${ owner }/${ name }`
)
Logger.notice(
`Successfully created milestone ${ nextMilestone } in ${ owner }/${ name }`
);
} );

View File

@ -1,24 +1,12 @@
/**
* External dependencies
*/
import { parse, inc } from 'semver';
import { setOutput } from '@actions/core';
/**
* Bumps the version according to WP rules.
*
* @param {string} version Version to increment
* @return {string} Incremented version
* Internal dependencies
*/
export const WPIncrement = ( version: string ): string => {
const parsedVersion = parse( version );
return inc( parsedVersion, parsedVersion.minor === 9 ? 'major' : 'minor' );
};
const getMajorMinor = ( version: string ) => {
const parsedVersion = parse( version );
return `${ parsedVersion.major }.${ parsedVersion.minor }`;
};
import { getMajorMinor } from '../../../core/version';
/**
* Set Github outputs.

View File

@ -2,7 +2,6 @@
* External dependencies
*/
import { Command } from '@commander-js/extra-typings';
import chalk from 'chalk';
import { setOutput } from '@actions/core';
/**
@ -14,6 +13,7 @@ import {
getToday,
getFutureDate,
} from './utils';
import { Logger } from '../../../core/logger';
export const verifyDayCommand = new Command( 'verify-day' )
.description( 'Verify if today is the code freeze day' )
@ -28,28 +28,18 @@ export const verifyDayCommand = new Command( 'verify-day' )
.action( ( { override, github } ) => {
const today = getToday( override );
const futureDate = getFutureDate( today );
console.log(
chalk.yellow( "Today's timestamp UTC is: " + today.toUTCString() )
);
console.log(
chalk.yellow(
`Checking to see if ${ DAYS_BETWEEN_CODE_FREEZE_AND_RELEASE } days from today is the second Tuesday of the month.`
)
Logger.warn( "Today's timestamp UTC is: " + today.toUTCString() );
Logger.warn(
`Checking to see if ${ DAYS_BETWEEN_CODE_FREEZE_AND_RELEASE } days from today is the second Tuesday of the month.`
);
const isCodeFreezeDay = isTodayCodeFreezeDay( override );
console.log(
chalk.green(
`${ futureDate.toUTCString() } ${
isCodeFreezeDay ? 'is' : 'is not'
} release day.`
)
Logger.notice(
`${ futureDate.toUTCString() } ${
isCodeFreezeDay ? 'is' : 'is not'
} release day.`
);
console.log(
chalk.green(
`Today is ${
isCodeFreezeDay ? 'indeed' : 'not'
} code freeze day.`
)
Logger.notice(
`Today is ${ isCodeFreezeDay ? 'indeed' : 'not' } code freeze day.`
);
if ( github ) {

View File

@ -1,7 +1,7 @@
/**
* Internal dependencies
*/
import { getLatestReleaseVersion } from '../repo';
import { getLatestGithubReleaseVersion } from '../repo';
jest.mock( '../api', () => {
return {
@ -50,7 +50,7 @@ jest.mock( '../api', () => {
it( 'should return the latest release version', async () => {
expect(
await getLatestReleaseVersion( {
await getLatestGithubReleaseVersion( {
owner: 'woocommerce',
name: 'woocommerce',
} )

View File

@ -8,7 +8,7 @@ import { Repository } from '@octokit/graphql-schema';
*/
import { graphqlWithAuth, octokitWithAuth } from './api';
export const getLatestReleaseVersion = async ( options: {
export const getLatestGithubReleaseVersion = async ( options: {
owner?: string;
name?: string;
} ): Promise< string > => {

View File

@ -0,0 +1,7 @@
/**
* External dependencies
*/
import { promisify } from 'util';
import { exec } from 'child_process';
export const execAsync = promisify( exec );

View File

@ -0,0 +1,26 @@
/**
* External dependencies
*/
import { parse, inc } from 'semver';
/**
* Bumps the version according to WP rules.
*
* @param {string} version Version to increment
* @return {string} Incremented version
*/
export const WPIncrement = ( version: string ): string => {
const parsedVersion = parse( version );
return inc( parsedVersion, parsedVersion.minor === 9 ? 'major' : 'minor' );
};
/**
* Gets the major-minor of a given version number.
*
* @param {string} version Version to gather major minor from.
* @return {string} major minor
*/
export const getMajorMinor = ( version: string ) => {
const parsedVersion = parse( version );
return `${ parsedVersion.major }.${ parsedVersion.minor }`;
};

View File

@ -3,60 +3,11 @@
*/
import { createServer, Server } from 'net';
import { join } from 'path';
import { writeFile } from 'fs/promises';
import { exec } from 'child_process';
import { promisify } from 'util';
export const execAsync = promisify( exec );
/**
* Format version string for regex.
*
* @param {string} rawVersion Raw version number.
* @return {string} version regex.
* Internal dependencies
*/
export const getVersionRegex = ( rawVersion: string ): string => {
const version = rawVersion.replace( /\./g, '\\.' );
if ( rawVersion.endsWith( '.0' ) ) {
return version + '|' + version.slice( 0, -3 ) + '\\n';
}
return version;
};
/**
* Get filename from patch
*
* @param {string} str String to extract filename from.
* @return {string} formatted filename.
*/
export const getFilename = ( str: string ): string => {
return str.replace( /^a(.*)\s.*/, '$1' );
};
/**
* Get patches
*
* @param {string} content Patch content.
* @param {RegExp} regex Regex to find specific patches.
* @return {string[]} Array of patches.
*/
export const getPatches = ( content: string, regex: RegExp ): string[] => {
const patches = content.split( 'diff --git ' );
const changes: string[] = [];
for ( const p in patches ) {
const patch = patches[ p ];
const id = patch.match( regex );
if ( id ) {
changes.push( patch );
}
}
return changes;
};
import { execAsync } from './util';
/**
* Determine if the default port for wp-env is already taken. If so, see
@ -149,24 +100,3 @@ export const stopWPEnv = async (
return false;
}
};
/**
* Generate a JSON file with the data passed.
*
* @param filePath - path to the file to be created.
* @param data - data to be written to the file.
* @return {Promise<void>} - promise that resolves when the file is written.
*/
export const generateJSONFile = ( filePath: string, data: unknown ) => {
const json = JSON.stringify(
data,
function replacer( _, value ) {
if ( value instanceof Map ) {
return Array.from( value.entries() );
}
return value;
},
2
);
return writeFile( filePath, json );
};

View File

@ -5,7 +5,8 @@ import semver from 'semver';
import { writeFile } from 'fs/promises';
import { tmpdir } from 'os';
import { join } from 'path';
import { Logger } from 'cli-core/src/logger';
import { Logger } from '@woocommerce/monorepo-utils/src/core/logger';
import { getEnvVar } from '@woocommerce/monorepo-utils/src/core/environment';
import { Command } from '@commander-js/extra-typings';
import dotenv from 'dotenv';
// @ts-expect-error - The enquirer types are incorrect.
@ -17,7 +18,6 @@ import { Select } from 'enquirer';
*/
import { renderTemplate } from '../../lib/render-template';
import { getWordpressComAuthToken } from '../../lib/oauth-helper';
import { getEnvVar } from '../../lib/environment';
import { getMostRecentFinal } from '../../lib/github-api';
import {
getFirstTuesdayOfTheMonth,

View File

@ -2,7 +2,7 @@
* External dependencies
*/
import { Command } from '@commander-js/extra-typings';
import { Logger } from 'cli-core/src/logger';
import { Logger } from '@woocommerce/monorepo-utils/src/core/logger';
import { writeFile } from 'fs/promises';
import { tmpdir } from 'os';
import { join } from 'path';

View File

@ -5,7 +5,8 @@ import semver from 'semver';
import { writeFile } from 'fs/promises';
import { tmpdir } from 'os';
import { join } from 'path';
import { Logger } from 'cli-core/src/logger';
import { Logger } from '@woocommerce/monorepo-utils/src/core/logger';
import { getEnvVar } from '@woocommerce/monorepo-utils/src/core/environment';
import { Command } from '@commander-js/extra-typings';
import dotenv from 'dotenv';
// @ts-expect-error - The enquirer types are incorrect.
@ -17,12 +18,8 @@ import { Select } from 'enquirer';
*/
import { renderTemplate } from '../../lib/render-template';
import { getWordpressComAuthToken } from '../../lib/oauth-helper';
import { getEnvVar } from '../../lib/environment';
import { getMostRecentBeta, getMostRecentFinal } from '../../lib/github-api';
import {
getFirstTuesdayOfTheMonth,
getSecondTuesdayOfTheMonth,
} from '../../lib/dates';
import { getMostRecentBeta } from '../../lib/github-api';
import { getSecondTuesdayOfTheMonth } from '../../lib/dates';
import {
createWpComDraftPost,
searchForPostsByCategory,

View File

@ -6,8 +6,12 @@ import semver from 'semver';
import { writeFile } from 'fs/promises';
import { tmpdir } from 'os';
import { join } from 'path';
import { cloneRepo, getCommitHash } from 'cli-core/src/git';
import { Logger } from 'cli-core/src/logger';
import {
cloneRepo,
getCommitHash,
} from '@woocommerce/monorepo-utils/src/core/git';
import { Logger } from '@woocommerce/monorepo-utils/src/core/logger';
import { getEnvVar } from '@woocommerce/monorepo-utils/src/core/environment';
import { Command } from '@commander-js/extra-typings';
import dotenv from 'dotenv';
@ -21,7 +25,6 @@ import {
editWpComPostContent,
} from '../../lib/draft-post';
import { getWordpressComAuthToken } from '../../lib/oauth-helper';
import { getEnvVar } from '../../lib/environment';
import { generateContributors } from '../../lib/contributors';
import { editPostHTML } from '../../lib/edit-post';

View File

@ -1,7 +1,10 @@
/**
* External dependencies
*/
import { checkoutRef, sparseCheckoutRepo } from 'cli-core/src/git';
import {
checkoutRef,
sparseCheckoutRepo,
} from '@woocommerce/monorepo-utils/src/core/git';
import { readFile } from 'fs/promises';
import { join } from 'path';
import semver from 'semver';

View File

@ -2,7 +2,7 @@
* External dependencies
*/
import fetch from 'node-fetch';
import { Logger } from 'cli-core/src/logger';
import { Logger } from '@woocommerce/monorepo-utils/src/core/logger';
// Typing just the things we need from the WP.com Post object.
// (which is not the same as WP Post object or API Post object).

View File

@ -1,16 +0,0 @@
/**
* External dependencies
*/
import { Logger } from 'cli-core/src/logger';
export const getEnvVar = ( varName: string, isRequired = false ) => {
const value = process.env[ varName ];
if ( value === undefined && isRequired ) {
Logger.error(
`You need to provide a value for ${ varName } in your environment either via an environment variable or the .env file.`
);
}
return value || '';
};

View File

@ -3,11 +3,7 @@
*/
import { Octokit } from '@octokit/rest';
import shuffle from 'lodash.shuffle';
/**
* Internal dependencies
*/
import { getEnvVar } from './environment';
import { getEnvVar } from '@woocommerce/monorepo-utils/src/core/environment';
export type ContributorData = {
totalCommits: number;

View File

@ -26,7 +26,7 @@
"dependencies": {
"@commander-js/extra-typings": "^0.1.0",
"@octokit/rest": "^19.0.4",
"cli-core": "workspace:*",
"@woocommerce/monorepo-utils": "workspace:*",
"code-analyzer": "workspace:*",
"commander": "9.4.0",
"dotenv": "^10.0.0",

View File

@ -2,7 +2,7 @@
* External dependencies
*/
import { prerelease } from 'semver';
import { Logger } from 'cli-core/src/logger';
import { Logger } from '@woocommerce/monorepo-utils/src/core/logger';
/**
* Internal dependencies

View File

@ -3,7 +3,7 @@
*/
import { readFile, writeFile, stat } from 'fs/promises';
import { join } from 'path';
import { Logger } from 'cli-core/src/logger';
import { Logger } from '@woocommerce/monorepo-utils/src/core/logger';
/**
* Internal dependencies

View File

@ -4,7 +4,7 @@
import { valid, lt as versionLessThan, parse } from 'semver';
import { join } from 'path';
import { readFile } from 'fs/promises';
import { Logger } from 'cli-core/src/logger';
import { Logger } from '@woocommerce/monorepo-utils/src/core/logger';
/**
* Internal dependencies

View File

@ -16,9 +16,9 @@
},
"dependencies": {
"@commander-js/extra-typings": "^0.1.0",
"@woocommerce/monorepo-utils": "workspace:*",
"chalk": "^4.1.2",
"commander": "9.4.0",
"cli-core": "workspace:*",
"express": "^4.18.1",
"ora": "^5.4.1",
"semver": "^7.3.2",