Skip to content

Commit

Permalink
Release v1.27.0
Browse files Browse the repository at this point in the history
Co-authored-by: o.drapeza <[email protected]>
GitOrigin-RevId: 3e46ea045d38a9c72512d4a4c244088fd0c5bbcb
  • Loading branch information
tinkoff-bot and o.drapeza committed Nov 8, 2021
1 parent 19036b1 commit 01c7209
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 28 deletions.
2 changes: 1 addition & 1 deletion packages-versions.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

{"@tramvai/cli":"1.26.1","@tramvai/core":"1.26.1","@tramvai/mock":"1.26.1","@tramvai/papi":"1.26.1","@tramvai/react":"1.26.1","@tramvai/react-query":"1.26.1","@tramvai/state":"1.26.1","@tramvai/types-actions-state-context":"1.26.1","@tramvai/test-unit-jest":"1.26.1","@tramvai/test-unit":"1.26.1","@tramvai/test-react":"1.26.1","@tramvai/test-puppeteer":"1.26.1","@tramvai/test-mocks":"1.26.1","@tramvai/test-jsdom":"1.26.1","@tramvai/test-integration-jest":"1.26.1","@tramvai/test-integration":"1.26.1","@tramvai/test-helpers":"1.26.1","@tramvai/tools-migrate":"0.5.118","@tramvai/tools-check-versions":"0.3.6","@tramvai/tools-generate-schema":"0.0.7","@tramvai/build":"2.6.1","@tinkoff-monorepo/depscheck":"1.8.4","@tinkoff-monorepo/fix-ts-references":"1.8.4","@tinkoff-monorepo/pkgs-collector":"1.8.4","@tinkoff-monorepo/pkgs-collector-dir":"1.8.4","@tinkoff-monorepo/pkgs-collector-workspaces":"1.8.4","@tramvai/tokens-common":"1.26.1","@tramvai/tokens-http-client":"1.26.1","@tramvai/tokens-metrics":"1.26.1","@tramvai/tokens-render":"1.26.1","@tramvai/tokens-router":"1.26.1","@tramvai/tokens-server":"1.26.1","@tramvai/module-common":"1.26.1","@tramvai/module-cookie":"1.26.1","@tramvai/module-environment":"1.26.1","@tramvai/module-log":"1.26.1","@tramvai/module-render":"1.26.1","@tramvai/module-server":"1.26.1","@tramvai/module-router":"1.26.1","@tramvai/module-http-client":"1.26.1","@tramvai/module-seo":"1.26.1","@tramvai/module-error-interceptor":"1.26.1","@tramvai/module-sentry":"1.26.1","@tramvai/module-metrics":"1.26.1","@tramvai/module-deps-graph":"1.26.1","@tramvai/module-react-query":"1.26.1","@tramvai/module-mocker":"1.26.1","@tramvai/module-cache-warmup":"1.26.1","@tramvai/module-client-hints":"1.26.1","@tramvai/module-autoscroll":"1.26.1","@tramvai/react-lazy-hydration-render":"0.1.28","@tramvai/safe-strings":"0.4.2","@tinkoff/errors":"0.2.18","@tinkoff/pubsub":"0.4.22","@tinkoff/url":"0.7.37","@tinkoff/browser-cookies":"1.4.2","@tinkoff/logger":"0.10.4","@tinkoff/is-modern-lib":"1.2.9","@tinkoff/minicss-class-generator":"0.1.13","@tinkoff/dippy":"0.7.35","@tinkoff/router":"0.1.60","@tinkoff/browserslist-config":"0.1.13","@tinkoff/layout-factory":"0.2.27","@tinkoff/user-agent":"0.3.138","@tinkoff/htmlpagebuilder":"0.4.22","@tinkoff/express-terminus":"0.1.11","@tinkoff/monkeypatch":"1.3.3","@tinkoff/meta-tags-generate":"0.4.26","@tinkoff/error-handlers":"0.4.26","@tinkoff/measure-express-requests":"1.4.2","@tinkoff/browser-timings":"0.9.4","@tinkoff/mocker":"1.5.2","@tinkoff/metrics-noop":"1.0.2","@tramvai/http-client":"0.1.22","@tramvai/tinkoff-request-http-client-adapter":"0.8.146","@tinkoff/react-hooks":"0.0.23","@tinkoff/hook-runner":"0.3.21","@tinkoff/eslint-plugin-tramvai":"0.5.12","prettier-config-tinkoff":"0.1.9","@tinkoff/pack-polyfills":"0.2.39","@tinkoff/package-manager-wrapper":"0.0.1"}
{"@tramvai/cli":"1.27.0","@tramvai/core":"1.27.0","@tramvai/mock":"1.27.0","@tramvai/papi":"1.27.0","@tramvai/react":"1.27.0","@tramvai/react-query":"1.27.0","@tramvai/state":"1.27.0","@tramvai/types-actions-state-context":"1.27.0","@tramvai/test-unit-jest":"1.27.0","@tramvai/test-unit":"1.27.0","@tramvai/test-react":"1.27.0","@tramvai/test-puppeteer":"1.27.0","@tramvai/test-mocks":"1.27.0","@tramvai/test-jsdom":"1.27.0","@tramvai/test-integration-jest":"1.27.0","@tramvai/test-integration":"1.27.0","@tramvai/test-helpers":"1.27.0","@tramvai/tools-migrate":"0.5.118","@tramvai/tools-check-versions":"0.3.6","@tramvai/tools-generate-schema":"0.0.7","@tramvai/build":"2.6.1","@tinkoff-monorepo/depscheck":"1.8.4","@tinkoff-monorepo/fix-ts-references":"1.8.4","@tinkoff-monorepo/pkgs-collector":"1.8.4","@tinkoff-monorepo/pkgs-collector-dir":"1.8.4","@tinkoff-monorepo/pkgs-collector-workspaces":"1.8.4","@tramvai/tokens-common":"1.27.0","@tramvai/tokens-http-client":"1.27.0","@tramvai/tokens-metrics":"1.27.0","@tramvai/tokens-render":"1.27.0","@tramvai/tokens-router":"1.27.0","@tramvai/tokens-server":"1.27.0","@tramvai/module-common":"1.27.0","@tramvai/module-cookie":"1.27.0","@tramvai/module-environment":"1.27.0","@tramvai/module-log":"1.27.0","@tramvai/module-render":"1.27.0","@tramvai/module-server":"1.27.0","@tramvai/module-router":"1.27.0","@tramvai/module-http-client":"1.27.0","@tramvai/module-seo":"1.27.0","@tramvai/module-error-interceptor":"1.27.0","@tramvai/module-sentry":"1.27.0","@tramvai/module-metrics":"1.27.0","@tramvai/module-deps-graph":"1.27.0","@tramvai/module-react-query":"1.27.0","@tramvai/module-mocker":"1.27.0","@tramvai/module-cache-warmup":"1.27.0","@tramvai/module-client-hints":"1.27.0","@tramvai/module-autoscroll":"1.27.0","@tramvai/react-lazy-hydration-render":"0.1.28","@tramvai/safe-strings":"0.4.2","@tinkoff/errors":"0.2.18","@tinkoff/pubsub":"0.4.22","@tinkoff/url":"0.7.37","@tinkoff/browser-cookies":"1.4.2","@tinkoff/logger":"0.10.4","@tinkoff/is-modern-lib":"1.2.9","@tinkoff/minicss-class-generator":"0.1.13","@tinkoff/dippy":"0.7.35","@tinkoff/router":"0.1.60","@tinkoff/browserslist-config":"0.1.13","@tinkoff/layout-factory":"0.2.27","@tinkoff/user-agent":"0.3.139","@tinkoff/htmlpagebuilder":"0.4.22","@tinkoff/express-terminus":"0.1.11","@tinkoff/monkeypatch":"1.3.3","@tinkoff/meta-tags-generate":"0.4.26","@tinkoff/error-handlers":"0.4.26","@tinkoff/measure-express-requests":"1.4.2","@tinkoff/browser-timings":"0.9.4","@tinkoff/mocker":"1.5.2","@tinkoff/metrics-noop":"1.0.2","@tramvai/http-client":"0.1.22","@tramvai/tinkoff-request-http-client-adapter":"0.8.147","@tinkoff/react-hooks":"0.0.23","@tinkoff/hook-runner":"0.3.21","@tinkoff/eslint-plugin-tramvai":"0.5.12","prettier-config-tinkoff":"0.1.9","@tinkoff/pack-polyfills":"0.2.39","@tinkoff/package-manager-wrapper":"0.0.1"}
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
"prettyoutput": "^1.2.0",
"process": "^0.11.10",
"promise-queue": "^2.2.5",
"p-map": "^4.0.0",
"react-refresh": "^0.10.0",
"resolve": "^1.19.0",
"rimraf": "^3.0.2",
Expand Down
9 changes: 2 additions & 7 deletions packages/cli/src/commands/update/checkVersionValidator.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import util from 'util';
import childProcess from 'child_process';
import { packageHasVersion } from '../../utils/commands/dependencies/packageHasVersion';
import type { Params } from './update';

const exec = util.promisify(childProcess.exec);

export const checkVersion = async (_, { to: version = 'latest' }: Params) => {
if (version === 'latest') {
return {
Expand All @@ -12,9 +9,7 @@ export const checkVersion = async (_, { to: version = 'latest' }: Params) => {
};
}

const { stdout } = await exec(`npm view @tramvai/core@${version} version`);

if (stdout.indexOf(version) !== -1) {
if (await packageHasVersion('@tramvai/core', version)) {
return {
name: 'checkVersion',
status: 'ok',
Expand Down
60 changes: 44 additions & 16 deletions packages/cli/src/commands/update/updatePackageJson.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { parse, minVersion } from 'semver';
import fs from 'fs';
import pMap from 'p-map';
import { getLatestPackageVersion } from '../../utils/commands/dependencies/getLatestPackageVersion';
import { packageHasVersion } from '../../utils/commands/dependencies/packageHasVersion';

// Список пакетов, не начинающихся с @tramvai,
// которые мы также хотим обновить
Expand All @@ -24,16 +26,48 @@ const updateEntry = async (
dep: string,
{ currentVersion, version }: { currentVersion: string; version: string }
) => {
let nextVersion: string;

if (dep.startsWith('@tramvai') && getVersionFromDep(deps[dep]) === currentVersion) {
console.log(`- ${dep}@${version}`);
// eslint-disable-next-line no-param-reassign
deps[dep] = version;
nextVersion = version;
} else if (shouldUpdateDependency(dep)) {
const latestPackageVersion = await getLatestPackageVersion(dep);
console.log(`- ${dep}@${latestPackageVersion}`);
// eslint-disable-next-line no-param-reassign
deps[dep] = latestPackageVersion;
nextVersion = latestPackageVersion;
}

if (nextVersion) {
const depHasVersion = await packageHasVersion(dep, nextVersion);

if (depHasVersion) {
console.log(`- ${dep}@${nextVersion}`);
// eslint-disable-next-line no-param-reassign
deps[dep] = nextVersion;
} else {
console.warn(
`⚠️ cannot update ${dep} to ${nextVersion} version, this version does not exist.
Maybe this package was removed or renamed.
Wait migrations, then manually update or remove dependency from package.json, if necessary.`
);
}
}
};

const updateDependencies = (
dependencies: Record<string, string> = {},
targetVersion: string,
currentVersion: string
) => {
return pMap<string, void>(
Object.keys(dependencies),
async (dep) => {
if (Object.prototype.hasOwnProperty.call(dependencies, dep)) {
await updateEntry(dependencies, dep, { currentVersion, version: targetVersion });
}
},
{
concurrency: 10,
}
);
};

export const updatePackageJson = async (version: string) => {
Expand All @@ -48,15 +82,9 @@ export const updatePackageJson = async (version: string) => {
process.exit(0);
}

for (const dep in content.dependencies) {
if (Object.prototype.hasOwnProperty.call(content.dependencies, dep)) {
await updateEntry(content.dependencies, dep, { currentVersion, version });
}
}
for (const dep in content.devDependencies) {
if (Object.prototype.hasOwnProperty.call(content.devDependencies, dep)) {
await updateEntry(content.devDependencies, dep, { currentVersion, version });
}
}
await updateDependencies(content.dependencies, version, currentVersion);
await updateDependencies(content.devDependencies, version, currentVersion);
await updateDependencies(content.peerDependencies, version, currentVersion);

fs.writeFileSync('package.json', JSON.stringify(content, null, 2));
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const checkVersions = async (context: Context) => {
console.log('Versions check completed');
} catch (e) {
spinner.stop();
console.error('Versions check error: ', e);
console.error('Versions check error:');
throw e;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const deduplicate = async (context: Context) => {
console.log('Deduplication completed');
} catch (e) {
spinner.stop();
console.error('Deduplication error: ', e);
console.error('Deduplication error:');
throw e;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const installDependencies = async (context: Context) => {
console.log('Dependencies installed');
} catch (e) {
spinner.stop();
console.error('Error installing dependencies: ', e);
console.error('Error installing dependencies:');
throw e;
}
};
2 changes: 1 addition & 1 deletion packages/cli/src/utils/commands/dependencies/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const migrate = async (context: Context) => {
console.log('Migrations completed');
} catch (e) {
spinner.stop();
console.error('Migrations error: ', e);
console.error('Migrations error:');
throw e;
}
};
14 changes: 14 additions & 0 deletions packages/cli/src/utils/commands/dependencies/packageHasVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import util from 'util';
import childProcess from 'child_process';

const exec = util.promisify(childProcess.exec);

export const packageHasVersion = async (packageName: string, version: string): Promise<boolean> => {
try {
const { stdout } = await exec(`npm view ${packageName}@${version} version`);
const hasVersion = !!stdout.trim().replace('\n', '');
return hasVersion;
} catch (e) {
return false;
}
};

0 comments on commit 01c7209

Please sign in to comment.