diff --git a/src/analyse/adapt-dependencies.ts b/src/analyse/adapt-dependencies.ts index 2846bd0..242c774 100644 --- a/src/analyse/adapt-dependencies.ts +++ b/src/analyse/adapt-dependencies.ts @@ -1,7 +1,5 @@ import * as semver from 'semver'; -import { clone } from 'ramda'; - import { white, green } from 'chalk'; import type { Module, PackageAfterDetermineVersion } from '../types'; @@ -20,8 +18,10 @@ export const adaptDependencies: Module = (env) => { } log('analyse affected packages'); - const clonePackages = clone(env.packages); - const releasablePackages = getReleasablePackages(clone(clonePackages)); + const clonePackages = structuredClone(env.packages); + const releasablePackages = getReleasablePackages( + structuredClone(clonePackages) + ); log(`${Object.keys(releasablePackages).length} packages will be released`); diff --git a/src/analyse/add-dependencies.ts b/src/analyse/add-dependencies.ts index b495cab..2944021 100644 --- a/src/analyse/add-dependencies.ts +++ b/src/analyse/add-dependencies.ts @@ -1,5 +1,3 @@ -import { clone } from 'ramda'; - import { Module, Package, @@ -20,7 +18,7 @@ export const addDependencies: Module = (env) => { throw new Error(errorMessage); } - const envPackages = clone(env.packages); + const envPackages = structuredClone(env.packages); const packagesNames = Object.keys(envPackages); diff --git a/src/analyse/add-messages-to-packages.ts b/src/analyse/add-messages-to-packages.ts index 4694d5d..0138def 100644 --- a/src/analyse/add-messages-to-packages.ts +++ b/src/analyse/add-messages-to-packages.ts @@ -1,5 +1,3 @@ -import { clone } from 'ramda'; - import type { Module } from '../types'; import { logger } from '../helpers/logger'; @@ -19,7 +17,7 @@ export const addMessagesToPackages: Module = (env) => { } log('Register messages to packages'); - const clonePackages = clone(env.packages); + const clonePackages = structuredClone(env.packages); env.commitMessages.forEach((commitMessage) => { commitMessage.affectedPackages?.forEach((affectedPackage) => { diff --git a/src/analyse/add-package-names-to-messages/add-package-names-to-messages.ts b/src/analyse/add-package-names-to-messages/add-package-names-to-messages.ts index 836648e..b61a240 100644 --- a/src/analyse/add-package-names-to-messages/add-package-names-to-messages.ts +++ b/src/analyse/add-package-names-to-messages/add-package-names-to-messages.ts @@ -19,7 +19,7 @@ export const addPackageNamesToMessages: Module = (env) => { log('Analyse affected packages per commit'); const userAffectedPackages = new Set(); - const cloneCommitMessages = clone(env.commitMessages); + const cloneCommitMessages = structuredClone(env.commitMessages); cloneCommitMessages.forEach((commitMessage) => { const affectedPackages = new Set(); diff --git a/src/analyse/add-package-names-to-messages/spec/add-package-names-to-messages.spec.ts b/src/analyse/add-package-names-to-messages/spec/add-package-names-to-messages.spec.ts index 381a377..5eb4e2a 100644 --- a/src/analyse/add-package-names-to-messages/spec/add-package-names-to-messages.spec.ts +++ b/src/analyse/add-package-names-to-messages/spec/add-package-names-to-messages.spec.ts @@ -1,6 +1,4 @@ /* eslint-env node, jest */ -import { clone } from 'ramda'; - import type { Env, Message, Module } from '../../../types'; import { envWithConfig } from '../../../fixtures/env'; @@ -57,7 +55,7 @@ describe('addPackageNamesToMessages Module', () => { }; const result = addPackageNamesToMessages(mockEnv); - const expectedEnv = clone(mockEnv); + const expectedEnv = structuredClone(mockEnv); expectedEnv.commitMessages![0].affectedPackages = ['package_1']; expectedEnv.commitMessages![1].affectedPackages = ['package_2']; expectedEnv.commitMessages![2].affectedPackages = ['package_3']; diff --git a/src/analyse/create-dependency-tree.ts b/src/analyse/create-dependency-tree.ts index 68fc75a..15dd14b 100644 --- a/src/analyse/create-dependency-tree.ts +++ b/src/analyse/create-dependency-tree.ts @@ -14,7 +14,7 @@ export const createDependencyTree: Module = (env) => { throw new Error(errorMessage); } - const packagesClone = clone(env.packages); + const packagesClone = structuredClone(env.packages); const counter = { default: 0, devDependencies: 0, diff --git a/src/analyse/create-package-json-content/create-package-json-content.ts b/src/analyse/create-package-json-content/create-package-json-content.ts index 3c01061..bc469fd 100644 --- a/src/analyse/create-package-json-content/create-package-json-content.ts +++ b/src/analyse/create-package-json-content/create-package-json-content.ts @@ -22,7 +22,7 @@ export const createPackageJsonContent: Module = (env) => { log('analyse packageJson Content'); - const clonePackages = clone(env.packages); + const clonePackages = structuredClone(env.packages); Object.keys(clonePackages).forEach((packageName) => { log(`generating git & npm package.json files for "${white(packageName)}"`); diff --git a/src/analyse/create-package-json-content/get-package-json.ts b/src/analyse/create-package-json-content/get-package-json.ts index 711d5dd..bcad029 100644 --- a/src/analyse/create-package-json-content/get-package-json.ts +++ b/src/analyse/create-package-json-content/get-package-json.ts @@ -28,7 +28,7 @@ function getPackageJson( const currentPackage = packages![packageName]; - const clonePackageJson = clone(currentPackage.packageJson); + const clonePackageJson = structuredClone(currentPackage.packageJson); const dependsOnMap = isNpm ? Object.fromEntries( currentPackage.dependsOn.map((dependency) => [ diff --git a/src/analyse/create-package-json-content/spec/create-package-json-content.spec.ts b/src/analyse/create-package-json-content/spec/create-package-json-content.spec.ts index 93d8d6b..705fc0f 100644 --- a/src/analyse/create-package-json-content/spec/create-package-json-content.spec.ts +++ b/src/analyse/create-package-json-content/spec/create-package-json-content.spec.ts @@ -1,6 +1,4 @@ /* eslint-env node, jest */ -import { clone } from 'ramda'; - import type { Env, Module, @@ -84,7 +82,7 @@ describe('createPackageJsonContent Module', () => { }); it('returns processed Env object', () => { - const cloneEnv = clone(mockEnvWithPackages); + const cloneEnv = structuredClone(mockEnvWithPackages); cloneEnv.packages!.mockPackage1 = { ...cloneEnv.packages!.mockPackage1, packageJsonGit: { name: 'mockPackage1', version: '*' }, diff --git a/src/analyse/determine-direct-increment.ts b/src/analyse/determine-direct-increment.ts index 57ace82..cf6bf5f 100644 --- a/src/analyse/determine-direct-increment.ts +++ b/src/analyse/determine-direct-increment.ts @@ -38,7 +38,7 @@ export const determineDirectIncrement: Module = (env) => { throw new Error(errorMessage); } - const clonePackages = clone(env.packages); + const clonePackages = structuredClone(env.packages); const packagesToRelease: Record = {}; log('analyse registered commitMessages'); diff --git a/src/analyse/determine-version.ts b/src/analyse/determine-version.ts index af2dc89..220969a 100644 --- a/src/analyse/determine-version.ts +++ b/src/analyse/determine-version.ts @@ -30,7 +30,7 @@ export const determineVersion: Module = (env) => { log('analyse packages'); - const clonePackages = clone(env.packages); + const clonePackages = structuredClone(env.packages); const incrementLevels: semver.ReleaseType[] = ['patch', 'minor', 'major']; diff --git a/src/analyse/extend-dependency-ranges.ts b/src/analyse/extend-dependency-ranges.ts index d07d842..45ca048 100644 --- a/src/analyse/extend-dependency-ranges.ts +++ b/src/analyse/extend-dependency-ranges.ts @@ -1,5 +1,3 @@ -import { clone } from 'ramda'; - import type { Module, RelatedPackageTypes } from '../types'; import { logger } from '../helpers/logger'; @@ -10,7 +8,7 @@ const { log } = logger('[analyse] extend dependency ranges'); const PINNED_VERSION_PATTERN = /^\d+\.\d+\.\d+$/; export const extendDependencyRanges: Module = (env) => { - const packagesClone = clone(env.packages); + const packagesClone = structuredClone(env.packages); log('Analysing packages'); let extendCounter = 0; diff --git a/src/analyse/prepare-changelogs.ts b/src/analyse/prepare-changelogs.ts index 4f94d49..50209e3 100644 --- a/src/analyse/prepare-changelogs.ts +++ b/src/analyse/prepare-changelogs.ts @@ -5,8 +5,6 @@ import { join } from 'path'; import semver from 'semver'; import { white } from 'chalk'; -import { clone } from 'ramda'; - import { getYearWeek } from '../helpers/get-week-number'; import type { @@ -38,7 +36,7 @@ export const prepareChangelogs: Module = (env) => { throw new Error(errorMessage); } - const clonePackages = clone(env.packages); + const clonePackages = structuredClone(env.packages); const releasablePackages = getReleasablePackages(clonePackages); if (!releasablePackages.length) { diff --git a/src/analyse/spec/adapt-dependencies.spec.ts b/src/analyse/spec/adapt-dependencies.spec.ts index bc66543..06afe1d 100644 --- a/src/analyse/spec/adapt-dependencies.spec.ts +++ b/src/analyse/spec/adapt-dependencies.spec.ts @@ -1,8 +1,6 @@ /* eslint-env node, jest */ import * as semver from 'semver'; -import { clone } from 'ramda'; - import type { Env, Module, @@ -410,7 +408,7 @@ describe('adaptDependencies Module', () => { ); it('returns an Env config object reflecting new ranges', () => { - const expectedEnv = clone(mockEnv); + const expectedEnv = structuredClone(mockEnv); expectedEnv.packages!.mockPackage4.relatedMessages.push({ date: new Date().toISOString(), diff --git a/src/analyse/spec/add-messages-to-packages.spec.ts b/src/analyse/spec/add-messages-to-packages.spec.ts index a66ef9d..a0982b3 100644 --- a/src/analyse/spec/add-messages-to-packages.spec.ts +++ b/src/analyse/spec/add-messages-to-packages.spec.ts @@ -1,6 +1,4 @@ /* eslint-env node, jest */ -import { clone } from 'ramda'; - import type { Env, Module, Package, Message } from '../../types'; import { envWithConfig } from '../../fixtures/env'; @@ -88,7 +86,7 @@ describe('addMessagesToPackages module', () => { }); it('throws an error when an invalid "affectedPackage" is registered', () => { - const mockInvalidAffectedPackageEnv = clone(mockEnv); + const mockInvalidAffectedPackageEnv = structuredClone(mockEnv); mockInvalidAffectedPackageEnv.commitMessages![1].affectedPackages!.push( 'lodash' ); @@ -106,7 +104,7 @@ describe('addMessagesToPackages module', () => { describe('on run', () => { let result: Env; - const expectedEnv = clone(mockEnv); + const expectedEnv = structuredClone(mockEnv); beforeAll(() => { expectedEnv.packages!.mock1Package.messages.push(mockCommitMessages[0]); diff --git a/src/analyse/spec/create-dependency-tree.spec.ts b/src/analyse/spec/create-dependency-tree.spec.ts index e8921f6..0c1ff0d 100644 --- a/src/analyse/spec/create-dependency-tree.spec.ts +++ b/src/analyse/spec/create-dependency-tree.spec.ts @@ -1,6 +1,4 @@ /* eslint-env node, jest */ -import { clone } from 'ramda'; - import type { Env, Module, Package } from '../../types'; import { envWithConfig } from '../../fixtures/env'; @@ -84,7 +82,7 @@ describe('[analyse] createDependencyTree module', () => { type: 'peer', }); - expectedPackages = clone(mockPackages); + expectedPackages = structuredClone(mockPackages); const mockEnv: Env = { ...envWithConfig, diff --git a/src/analyse/spec/determine-direct-increment.spec.ts b/src/analyse/spec/determine-direct-increment.spec.ts index 4556cf5..8a6b54a 100644 --- a/src/analyse/spec/determine-direct-increment.spec.ts +++ b/src/analyse/spec/determine-direct-increment.spec.ts @@ -1,7 +1,5 @@ /* eslint-env node, jest */ -import { clone } from 'ramda'; - import { envWithConfig } from '../../fixtures/env'; import type { Env, Message, Module, Package } from '../../types'; @@ -105,7 +103,7 @@ describe('determineDirectIncrement Module', () => { packages: mockEnvPackages, commitMessages: mockCommitMessages, }; - const expectedEnv: Env = clone(mockEnv); + const expectedEnv: Env = structuredClone(mockEnv); const { mock1Package, mock2Package, mock3Package, mock4Package } = expectedEnv.packages!; beforeAll(() => { diff --git a/src/analyse/spec/determine-version.spec.ts b/src/analyse/spec/determine-version.spec.ts index e3082d2..9f09395 100644 --- a/src/analyse/spec/determine-version.spec.ts +++ b/src/analyse/spec/determine-version.spec.ts @@ -1,8 +1,6 @@ /* eslint-env node, jest */ import { inc, parse } from 'semver'; -import { clone } from 'ramda'; - import type { Env, Module, @@ -101,7 +99,7 @@ describe('determineVersion Module', () => { const expectedErrorMessage = 'Invalid version "latest" for package "mock0Package"'; mockParse.mockImplementationOnce(() => null); - const mockWrongVersionEnv: Env = clone(mockEnv); + const mockWrongVersionEnv: Env = structuredClone(mockEnv); mockWrongVersionEnv.packages!.mock0Package.currentVersion = 'latest'; expect(() => determineVersion(mockWrongVersionEnv)).toThrow( @@ -115,7 +113,7 @@ describe('determineVersion Module', () => { mockInc.mockImplementationOnce(() => null); const expectedErrorMessage = 'version "1.0.0" cannot be increased to "patch" for package "mock0Package"'; - const mockWrongVersionEnv: Env = clone(mockEnv); + const mockWrongVersionEnv: Env = structuredClone(mockEnv); expect(() => determineVersion(mockWrongVersionEnv)).toThrow( expectedErrorMessage @@ -126,7 +124,7 @@ describe('determineVersion Module', () => { describe('on run', () => { let result: Env; - const expectedEnv: Env = clone(mockEnv); + const expectedEnv: Env = structuredClone(mockEnv); ( expectedEnv.packages!.mock0Package as PackageAfterDetermineVersion ).incrementedVersion = '1.0.1'; diff --git a/src/analyse/spec/extend-dependency-range.spec.ts b/src/analyse/spec/extend-dependency-range.spec.ts index 5f9aa98..fd6c782 100644 --- a/src/analyse/spec/extend-dependency-range.spec.ts +++ b/src/analyse/spec/extend-dependency-range.spec.ts @@ -1,6 +1,4 @@ /* eslint-env node, jest */ -import { clone } from 'ramda'; - import type { Env, Module, Package } from '../../types'; import { envWithConfig } from '../../fixtures/env'; @@ -75,7 +73,7 @@ describe('ExtendDependencyRange Module', () => { }); const mockEnv: Env = { ...envWithConfig, packages: mockPackages }; - expectedPackages = clone(mockPackages); + expectedPackages = structuredClone(mockPackages); expectedPackages['test-package-1'].dependsOn[1].range = '~1.0.0'; expectedPackages['test-package-1'].determinedIncrementLevel = 0; expectedPackages['test-package-1'].relatedMessages.push({ diff --git a/src/analyse/spec/prepare-changelogs.spec.ts b/src/analyse/spec/prepare-changelogs.spec.ts index 9291024..7e5b77b 100644 --- a/src/analyse/spec/prepare-changelogs.spec.ts +++ b/src/analyse/spec/prepare-changelogs.spec.ts @@ -1,5 +1,3 @@ -import { clone } from 'ramda'; - import type { Env, Message, @@ -84,7 +82,7 @@ const invalidMockEnv: Env = { describe('prepareChangelogs Module', () => { let prepareChangelogs: Module; let result: Env; - let expectedEnv: Env = clone(mockEnv); + let expectedEnv: Env = structuredClone(mockEnv); beforeAll(() => { jest.useFakeTimers('modern').setSystemTime(new Date('2022, 1, 3')); @@ -156,7 +154,7 @@ describe('prepareChangelogs Module', () => { }); it('throws an error when messages are missing for the package', () => { - const invalidMockEnv = clone(mockEnv); + const invalidMockEnv = structuredClone(mockEnv); invalidMockEnv.packages!.mock2Package.messages = []; invalidMockEnv.packages!.mock2Package.relatedMessages = []; const expectedErrorMessage = `No messages found for "white(mock2Package)"`; diff --git a/src/change/spec/write-main-changelog.spec.ts b/src/change/spec/write-main-changelog.spec.ts index b173a9c..55dd602 100644 --- a/src/change/spec/write-main-changelog.spec.ts +++ b/src/change/spec/write-main-changelog.spec.ts @@ -1,7 +1,5 @@ import fs from 'fs'; -import { clone } from 'ramda'; - import { envWithConfig } from '../../fixtures/env'; import type { Module, Env, Message, RelatedMessage } from '../../types'; @@ -74,7 +72,7 @@ describe('writeMainChangelog Module', () => { const expectedErrorMessage = '"changelogPath" attribute not found on env config object'; - const invalidEnvConfig = clone(envWithConfig); + const invalidEnvConfig = structuredClone(envWithConfig); invalidEnvConfig.config!.changelogPath = ''; expect(() => writeMainChangelog(invalidEnvConfig)).toThrow( diff --git a/src/change/write-package-changelogs.ts b/src/change/write-package-changelogs.ts index 8bdb423..24bcbb0 100644 --- a/src/change/write-package-changelogs.ts +++ b/src/change/write-package-changelogs.ts @@ -20,7 +20,9 @@ export const writePackageChangelogs: Module = (env) => { error(errorMessage); throw new Error(errorMessage); } - const releasablePackages = getReleasablePackages(clone(env.packages)); + const releasablePackages = getReleasablePackages( + structuredClone(env.packages) + ); releasablePackages.forEach((packageName) => { const currentPackage = env.packages![ diff --git a/src/helpers/spec/plugins.spec.ts b/src/helpers/spec/plugins.spec.ts index 4baa167..67ab2d9 100644 --- a/src/helpers/spec/plugins.spec.ts +++ b/src/helpers/spec/plugins.spec.ts @@ -1,5 +1,3 @@ -import { clone } from 'ramda'; - import type { Env, Module, Phase } from '../../types'; import { composeAsync } from '../compose-async'; @@ -36,7 +34,7 @@ jest.doMock('test-plugin-package-2', () => mockPluginPackage2, { import { envWithConfig } from '../../fixtures/env'; const mockEnv = { ...envWithConfig }; -const mockEnvWithPlugins = clone(mockEnv); +const mockEnvWithPlugins = structuredClone(mockEnv); mockEnvWithPlugins.config!.plugins = [ 'test-plugin-package-1', 'test-plugin-package-2', diff --git a/src/persist/commit-and-tag-packages.ts b/src/persist/commit-and-tag-packages.ts index 38c14da..cae8aee 100644 --- a/src/persist/commit-and-tag-packages.ts +++ b/src/persist/commit-and-tag-packages.ts @@ -1,5 +1,3 @@ -import { clone } from 'ramda'; - import simpleGit from 'simple-git'; import type { Env, Module, PackageAfterPrepareChangelogs } from '../types'; @@ -28,7 +26,9 @@ const commitAndTagPackages: Module = async (env: Env) => { }); }; - const releasablePackages = getReleasablePackages(clone(env.packages!)); + const releasablePackages = getReleasablePackages( + structuredClone(env.packages!) + ); const commitMessageStr = `chore(release): publish new version ${prepareCommit(releasablePackages).join('\n')}`;