diff --git a/.yarnrc.yml b/.yarnrc.yml index ff4d9c0ab92..1eb1c359bb8 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -3,3 +3,5 @@ nmHoistingLimits: none nodeLinker: node-modules yarnPath: .yarn/releases/yarn-4.6.0.cjs + +npmRegistryServer: "https://registry.npmjs.org/" diff --git a/packages/eui-theme-borealis/package.json b/packages/eui-theme-borealis/package.json index 334c7aebe99..6008f999724 100644 --- a/packages/eui-theme-borealis/package.json +++ b/packages/eui-theme-borealis/package.json @@ -32,7 +32,7 @@ "@babel/preset-env": "^7.21.5", "@babel/preset-react": "^7.18.6", "@babel/preset-typescript": "^7.21.5", - "@elastic/eui-theme-common": "workspace:^", + "@elastic/eui-theme-common": "workspace:*", "@types/chroma-js": "^2.4.0", "@types/jest": "^29.5.12", "@types/prettier": "2.7.3", diff --git a/packages/eui-theme-common/package.json b/packages/eui-theme-common/package.json index d19ef7fdc02..acbf18d18be 100644 --- a/packages/eui-theme-common/package.json +++ b/packages/eui-theme-common/package.json @@ -1,6 +1,6 @@ { "name": "@elastic/eui-theme-common", - "version": "0.0.9", + "version": "0.0.11", "description": "EUI theme common", "license": "SEE LICENSE IN LICENSE.txt", "scripts": { diff --git a/packages/eui/package.json b/packages/eui/package.json index 8e7de031d5d..e4adeabe88d 100644 --- a/packages/eui/package.json +++ b/packages/eui/package.json @@ -52,7 +52,7 @@ "url": "https://github.com/elastic/eui.git" }, "dependencies": { - "@elastic/eui-theme-common": "workspace:^", + "@elastic/eui-theme-common": "workspace:*", "@elastic/prismjs-esql": "^1.0.0", "@hello-pangea/dnd": "^16.6.0", "@types/lodash": "^4.14.202", @@ -106,7 +106,7 @@ "@cypress/webpack-dev-server": "^1.7.0", "@elastic/charts": "^64.1.0", "@elastic/datemath": "^5.0.3", - "@elastic/eui-theme-borealis": "workspace:^", + "@elastic/eui-theme-borealis": "workspace:*", "@emotion/babel-preset-css-prop": "^11.11.0", "@emotion/cache": "^11.11.0", "@emotion/css": "^11.11.0", diff --git a/packages/release-cli/src/steps/update_versions.ts b/packages/release-cli/src/steps/update_versions.ts index 13ad1a21d95..d9a5bab378a 100644 --- a/packages/release-cli/src/steps/update_versions.ts +++ b/packages/release-cli/src/steps/update_versions.ts @@ -19,7 +19,12 @@ import { deleteObsoleteChangelogs, updateChangelogContent, } from '../update_changelog'; -import { getUpcomingVersion, getVersionTypeFromChangelog } from '../version'; +import { + getUniqueSnapshotId, + getUpcomingSnapshotVersion, + getUpcomingVersion, + getVersionTypeFromChangelog, +} from '../version'; import { commitFiles, isFileAddedToGit, stageFiles } from '../git_utils'; /** @@ -37,6 +42,7 @@ export const stepUpdateVersions = async ( const filesToCommit: string[] = []; const changedWorkspaces: YarnWorkspace[] = []; const rootWorkspaceDir = getRootWorkspaceDir(); + const snapshotId = getUniqueSnapshotId(); for (const workspace of workspaces) { logger.debug(`Calculating changes in ${workspace.name}`); @@ -44,42 +50,49 @@ export const stepUpdateVersions = async ( const workspaceDir = path.join(rootWorkspaceDir, workspace.location); const currentVersion = await getWorkspacePackageVersion(workspaceDir); - const { changelogMap, changelog, hasChanges, processedChangelogFiles } = - await collateChangelogFiles(workspaceDir); + if (options.type === 'snapshot') { + const newVersion = getUpcomingSnapshotVersion(currentVersion, snapshotId); + await updateWorkspaceVersion(workspace.name, newVersion); - if (!hasChanges) { - logger.debug(`[${workspace.name}] No changes detected`); - continue; - } + logger.info(`[${workspace.name}] Updating version ${currentVersion} -> ${newVersion}`); + } else { + const { changelogMap, changelog, hasChanges, processedChangelogFiles } = + await collateChangelogFiles(workspaceDir); - const versionType = getVersionTypeFromChangelog(changelogMap); - const newVersion = getUpcomingVersion(currentVersion, versionType); + if (!hasChanges) { + logger.debug(`[${workspace.name}] No changes detected`); + continue; + } - const statsStr = Object.entries(changelogMap) - .filter(([_, items]) => items.length) - .map(([name, items]) => `${items.length} ${name.toLowerCase()}`); + const versionType = getVersionTypeFromChangelog(changelogMap); + const newVersion = getUpcomingVersion(currentVersion, versionType); - logger.info( - `[${workspace.name}] Updating version ${currentVersion} -> ${newVersion} (${versionType} update; ${statsStr})` - ); + const statsStr = Object.entries(changelogMap) + .filter(([_, items]) => items.length) + .map(([name, items]) => `${items.length} ${name.toLowerCase()}`); - const updatedYearChangelogPath = await updateChangelogContent( - workspaceDir, - changelog, - newVersion - ); - await deleteObsoleteChangelogs(processedChangelogFiles); + logger.info( + `[${workspace.name}] Updating version ${currentVersion} -> ${newVersion} (${versionType} update; ${statsStr})` + ); - // Update package.json version string - await updateWorkspaceVersion(workspace.name, newVersion); + const updatedYearChangelogPath = await updateChangelogContent( + workspaceDir, + changelog, + newVersion + ); + await deleteObsoleteChangelogs(processedChangelogFiles); - filesToCommit.push(getWorkspacePackageJsonPath(workspaceDir)); - filesToCommit.push(updatedYearChangelogPath); + // Update package.json version string + await updateWorkspaceVersion(workspace.name, newVersion); - // Only stage and commit changelog files that are added to git (versioned) - for (const file of processedChangelogFiles) { - if (await isFileAddedToGit(file)) { - filesToCommit.push(file); + filesToCommit.push(getWorkspacePackageJsonPath(workspaceDir)); + filesToCommit.push(updatedYearChangelogPath); + + // Only stage and commit changelog files that are added to git (versioned) + for (const file of processedChangelogFiles) { + if (await isFileAddedToGit(file)) { + filesToCommit.push(file); + } } } @@ -90,16 +103,18 @@ export const stepUpdateVersions = async ( throw new Error('There are no changes to release'); } - // Stage yarn.lock changes - const yarnLockPath = path.join(rootWorkspaceDir, 'yarn.lock'); - filesToCommit.push(yarnLockPath); - await stageFiles([yarnLockPath]); + if (options.type !== 'snapshot') { + // Stage yarn.lock changes + const yarnLockPath = path.join(rootWorkspaceDir, 'yarn.lock'); + filesToCommit.push(yarnLockPath); + await stageFiles([yarnLockPath]); - // Stage updated package.json files - await stageFiles(filesToCommit); + // Stage updated package.json files + await stageFiles(filesToCommit); - // Commit all package.json files and yarn.lock - await commitFiles('chore: update package versions [skip ci]', filesToCommit); + // Commit all package.json files and yarn.lock + await commitFiles('chore: update package versions [skip ci]', filesToCommit); + } return changedWorkspaces; }; diff --git a/packages/release-cli/src/version.ts b/packages/release-cli/src/version.ts index d8c1a3ef27c..82fac2da8ac 100644 --- a/packages/release-cli/src/version.ts +++ b/packages/release-cli/src/version.ts @@ -56,6 +56,16 @@ export const getUpcomingVersion = (currentVersion: string, target: string): stri return [major, minor, patch].join('.'); }; +export const getUpcomingSnapshotVersion = (currentVersion: string, uniqueId: string): string => { + // remove preid part of the version string if exists + const [version, _] = currentVersion.split('-'); + return `${version}-snapshot.${uniqueId}`; +}; + +export const getUniqueSnapshotId = () => { + return Date.now().toString(); +} + export const getVersionTypeFromChangelog = (changelogMap: ChangelogMap): VersionType => { const hasFeatures = changelogMap['Features'].length > 0; const hasBugFixes = changelogMap['Bug fixes'].length > 0; diff --git a/yarn.lock b/yarn.lock index 209b9cdc5a9..da00c7c3d8c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4672,7 +4672,7 @@ __metadata: languageName: unknown linkType: soft -"@elastic/eui-theme-borealis@workspace:^, @elastic/eui-theme-borealis@workspace:packages/eui-theme-borealis": +"@elastic/eui-theme-borealis@workspace:*, @elastic/eui-theme-borealis@workspace:^, @elastic/eui-theme-borealis@workspace:packages/eui-theme-borealis": version: 0.0.0-use.local resolution: "@elastic/eui-theme-borealis@workspace:packages/eui-theme-borealis" dependencies: @@ -4681,7 +4681,7 @@ __metadata: "@babel/preset-env": "npm:^7.21.5" "@babel/preset-react": "npm:^7.18.6" "@babel/preset-typescript": "npm:^7.21.5" - "@elastic/eui-theme-common": "workspace:^" + "@elastic/eui-theme-common": "workspace:*" "@types/chroma-js": "npm:^2.4.0" "@types/jest": "npm:^29.5.12" "@types/prettier": "npm:2.7.3" @@ -4706,7 +4706,7 @@ __metadata: languageName: unknown linkType: soft -"@elastic/eui-theme-common@workspace:^, @elastic/eui-theme-common@workspace:packages/eui-theme-common": +"@elastic/eui-theme-common@workspace:*, @elastic/eui-theme-common@workspace:^, @elastic/eui-theme-common@workspace:packages/eui-theme-common": version: 0.0.0-use.local resolution: "@elastic/eui-theme-common@workspace:packages/eui-theme-common" dependencies: @@ -4822,8 +4822,8 @@ __metadata: "@cypress/webpack-dev-server": "npm:^1.7.0" "@elastic/charts": "npm:^64.1.0" "@elastic/datemath": "npm:^5.0.3" - "@elastic/eui-theme-borealis": "workspace:^" - "@elastic/eui-theme-common": "workspace:^" + "@elastic/eui-theme-borealis": "workspace:*" + "@elastic/eui-theme-common": "workspace:*" "@elastic/prismjs-esql": "npm:^1.0.0" "@emotion/babel-preset-css-prop": "npm:^11.11.0" "@emotion/cache": "npm:^11.11.0"