Skip to content

Commit

Permalink
refactor: use workspace: protocol for linking workspace packages (#…
Browse files Browse the repository at this point in the history
…2881)

* refactor: use workspace protocol for linking workspace packages

* refactor(scripts/install-template): avoid installation, assert state

* chore: debug logs

* fix: ensure path exists

* refactor(scripts/install-template): improve assertions

* chore: clean up unused scripts

* refactor(scripts/install-template): remove some assertions

* chore: update uikit to v15.6.0
  • Loading branch information
emmenko committed Dec 19, 2022
1 parent adb731a commit e3ffe6c
Show file tree
Hide file tree
Showing 37 changed files with 385 additions and 412 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-queens-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-frontend/create-mc-app': patch
---

Ensure the latest App Kit release is used in the template projects.
27 changes: 27 additions & 0 deletions .changeset/weak-seahorses-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
'@commercetools-applications/merchant-center-template-starter': patch
'@commercetools-applications/merchant-center-template-starter-typescript': patch
'@commercetools-frontend/actions-global': patch
'@commercetools-frontend/application-components': patch
'@commercetools-frontend/application-config': patch
'@commercetools-frontend/application-shell': patch
'@commercetools-frontend/application-shell-connectors': patch
'@commercetools-frontend/create-mc-app': patch
'@commercetools-frontend/cypress': patch
'@commercetools-frontend/eslint-config-mc-app': patch
'@commercetools-frontend/i18n': patch
'@commercetools-frontend/jest-preset-mc-app': patch
'@commercetools-frontend/l10n': patch
'@commercetools-frontend/mc-dev-authentication': patch
'@commercetools-frontend/mc-html-template': patch
'@commercetools-frontend/mc-scripts': patch
'@commercetools-frontend/permissions': patch
'@commercetools-frontend/react-notifications': patch
'@commercetools-frontend/sdk': patch
'@commercetools-frontend/sentry': patch
'@commercetools-local/playground': patch
'@commercetools-local/visual-testing-app': patch
'@commercetools-website/components-playground': patch
---

Use `workspace:` version syntax for link workspace packages
4 changes: 2 additions & 2 deletions .github/actions/ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ runs:

- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
run: echo "DIR=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
shell: bash

- uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache.outputs.dir }}
path: ${{ steps.yarn-cache.outputs.DIR }}
key: ${{ runner.os }}-yarn-v1-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-v1-
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,8 @@ jobs:
- name: Installing dependencies and building packages
uses: ./.github/actions/ci

- name: Preparing tarballs of packages for testing templates installation
run: node ./scripts/build-tarballs.js

- name: Installing and building template starter
run: node ./scripts/install-template.js
run: node ./scripts/install-template.mjs
env:
TEMPLATE_NAME: starter
CTP_INITIAL_PROJECT_KEY: ${{ secrets.CYPRESS_PROJECT_KEY }}
Expand Down Expand Up @@ -226,11 +223,8 @@ jobs:
- name: Installing dependencies and building packages
uses: ./.github/actions/ci

- name: Preparing tarballs of packages for testing templates installation
run: node ./scripts/build-tarballs.js

- name: Installing and building template starter
run: node ./scripts/install-template.js
run: node ./scripts/install-template.mjs
env:
TEMPLATE_NAME: starter-typescript
CTP_INITIAL_PROJECT_KEY: ${{ secrets.CYPRESS_PROJECT_KEY }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

- name: Storing release version for changeset
id: release_version
run: echo "::set-output name=value::$(./scripts/print_release_version.sh)"
run: echo "VALUE=$(./scripts/print_release_version.sh)" >> $GITHUB_OUTPUT
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
Expand All @@ -49,8 +49,8 @@ jobs:
version: yarn changeset:version-and-format
commit: 'ci(changesets): version packages'
createGithubReleases: aggregate
githubReleaseName: v${{ steps.release_version.outputs.value }}
githubTagName: v${{ steps.release_version.outputs.value }}
githubReleaseName: v${{ steps.release_version.outputs.VALUE }}
githubTagName: v${{ steps.release_version.outputs.VALUE }}
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
SKIP_POSTINSTALL_DEV_SETUP: true
Expand Down
27 changes: 13 additions & 14 deletions application-templates/starter-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"description": "A starter example in TypeScript for the bare minimum setup to develop a Merchant Center Application",
"private": true,
"scripts": {
"postinstall": "manypkg check",
"build": "mc-scripts build",
"start": "mc-scripts start",
"compile-html": "mc-scripts compile-html",
Expand All @@ -21,19 +20,19 @@
},
"dependencies": {
"@apollo/client": "3.7.0",
"@commercetools-frontend/actions-global": "21.21.0",
"@commercetools-frontend/application-components": "21.21.0",
"@commercetools-frontend/application-config": "21.21.0",
"@commercetools-frontend/application-shell": "21.21.0",
"@commercetools-frontend/application-shell-connectors": "21.21.0",
"@commercetools-frontend/assets": "21.21.0",
"@commercetools-frontend/constants": "21.21.0",
"@commercetools-frontend/eslint-config-mc-app": "21.21.0",
"@commercetools-frontend/i18n": "21.21.0",
"@commercetools-frontend/jest-preset-mc-app": "21.21.0",
"@commercetools-frontend/mc-dev-authentication": "21.21.0",
"@commercetools-frontend/mc-scripts": "21.21.0",
"@commercetools-frontend/permissions": "21.21.0",
"@commercetools-frontend/actions-global": "workspace:*",
"@commercetools-frontend/application-components": "workspace:*",
"@commercetools-frontend/application-config": "workspace:*",
"@commercetools-frontend/application-shell": "workspace:*",
"@commercetools-frontend/application-shell-connectors": "workspace:*",
"@commercetools-frontend/assets": "workspace:*",
"@commercetools-frontend/constants": "workspace:*",
"@commercetools-frontend/eslint-config-mc-app": "workspace:*",
"@commercetools-frontend/i18n": "workspace:*",
"@commercetools-frontend/jest-preset-mc-app": "workspace:*",
"@commercetools-frontend/mc-dev-authentication": "workspace:*",
"@commercetools-frontend/mc-scripts": "workspace:*",
"@commercetools-frontend/permissions": "workspace:*",
"@commercetools-test-data/channel": "4.1.1",
"@commercetools-test-data/commons": "4.1.1",
"@commercetools-test-data/core": "4.1.1",
Expand Down
25 changes: 12 additions & 13 deletions application-templates/starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"description": "A starter example for the bare minimum setup to develop a Merchant Center Application",
"private": true,
"scripts": {
"postinstall": "manypkg check",
"build": "mc-scripts build",
"start": "mc-scripts start",
"compile-html": "mc-scripts compile-html",
Expand All @@ -20,18 +19,18 @@
},
"dependencies": {
"@apollo/client": "3.7.0",
"@commercetools-frontend/actions-global": "21.21.0",
"@commercetools-frontend/application-components": "21.21.0",
"@commercetools-frontend/application-shell": "21.21.0",
"@commercetools-frontend/application-shell-connectors": "21.21.0",
"@commercetools-frontend/assets": "21.21.0",
"@commercetools-frontend/constants": "21.21.0",
"@commercetools-frontend/eslint-config-mc-app": "21.21.0",
"@commercetools-frontend/i18n": "21.21.0",
"@commercetools-frontend/jest-preset-mc-app": "21.21.0",
"@commercetools-frontend/mc-dev-authentication": "21.21.0",
"@commercetools-frontend/mc-scripts": "21.21.0",
"@commercetools-frontend/permissions": "21.21.0",
"@commercetools-frontend/actions-global": "workspace:*",
"@commercetools-frontend/application-components": "workspace:*",
"@commercetools-frontend/application-shell": "workspace:*",
"@commercetools-frontend/application-shell-connectors": "workspace:*",
"@commercetools-frontend/assets": "workspace:*",
"@commercetools-frontend/constants": "workspace:*",
"@commercetools-frontend/eslint-config-mc-app": "workspace:*",
"@commercetools-frontend/i18n": "workspace:*",
"@commercetools-frontend/jest-preset-mc-app": "workspace:*",
"@commercetools-frontend/mc-dev-authentication": "workspace:*",
"@commercetools-frontend/mc-scripts": "workspace:*",
"@commercetools-frontend/permissions": "workspace:*",
"@commercetools-test-data/channel": "4.1.1",
"@commercetools-test-data/commons": "4.1.1",
"@commercetools-test-data/core": "4.1.1",
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@
"generate-types:core": "graphql-codegen -r dotenv/config --config codegen.core.yml",
"generate-types:settings": "graphql-codegen -r dotenv/config --config codegen.settings.yml",
"generate-types:proxy": "graphql-codegen -r dotenv/config --config codegen.proxy.yml",
"generate-types": "yarn generate-types:mc && yarn generate-types:ctp && yarn generate-types:core && yarn generate-types:settings && yarn generate-types:proxy",
"versions:uikit": "manypkg upgrade @commercetools-uikit",
"versions:docskit": "manypkg upgrade @commercetools-docs"
"generate-types": "yarn generate-types:mc && yarn generate-types:ctp && yarn generate-types:core && yarn generate-types:settings && yarn generate-types:proxy"
},
"workspaces": {
"packages": [
Expand Down
8 changes: 4 additions & 4 deletions packages/actions-global/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"dependencies": {
"@babel/runtime": "^7.19.0",
"@babel/runtime-corejs3": "^7.19.0",
"@commercetools-frontend/browser-history": "21.21.0",
"@commercetools-frontend/constants": "21.21.0",
"@commercetools-frontend/notifications": "21.21.0",
"@commercetools-frontend/sentry": "21.21.0",
"@commercetools-frontend/browser-history": "workspace:*",
"@commercetools-frontend/constants": "workspace:*",
"@commercetools-frontend/notifications": "workspace:*",
"@commercetools-frontend/sentry": "workspace:*",
"@types/lodash": "^4.14.185",
"@types/react": "^17.0.49",
"@types/react-redux": "^7.1.24",
Expand Down
10 changes: 5 additions & 5 deletions packages/application-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
"dependencies": {
"@babel/runtime": "^7.19.0",
"@babel/runtime-corejs3": "^7.19.0",
"@commercetools-frontend/application-shell-connectors": "21.21.0",
"@commercetools-frontend/assets": "21.21.0",
"@commercetools-frontend/constants": "21.21.0",
"@commercetools-frontend/i18n": "21.21.0",
"@commercetools-frontend/l10n": "21.21.0",
"@commercetools-frontend/application-shell-connectors": "workspace:*",
"@commercetools-frontend/assets": "workspace:*",
"@commercetools-frontend/constants": "workspace:*",
"@commercetools-frontend/i18n": "workspace:*",
"@commercetools-frontend/l10n": "workspace:*",
"@commercetools-uikit/card": "^15.6.0",
"@commercetools-uikit/constraints": "^15.6.0",
"@commercetools-uikit/design-system": "^15.6.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/application-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@babel/register": "^7.18.9",
"@babel/runtime": "^7.19.0",
"@babel/runtime-corejs3": "^7.19.0",
"@commercetools-frontend/babel-preset-mc-app": "21.21.0",
"@commercetools-frontend/babel-preset-mc-app": "workspace:*",
"ajv": "8.11.0",
"core-js": "^3.25.1",
"cosmiconfig": "7.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/application-shell-connectors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"dependencies": {
"@babel/runtime": "^7.19.0",
"@babel/runtime-corejs3": "^7.19.0",
"@commercetools-frontend/constants": "21.21.0",
"@commercetools-frontend/sentry": "21.21.0",
"@commercetools-frontend/constants": "workspace:*",
"@commercetools-frontend/sentry": "workspace:*",
"@emotion/react": "11.10.4",
"@types/lodash": "^4.14.185",
"@types/prop-types": "^15.7.5",
Expand Down
30 changes: 15 additions & 15 deletions packages/application-shell/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@
"dependencies": {
"@babel/runtime": "^7.19.0",
"@babel/runtime-corejs3": "^7.19.0",
"@commercetools-frontend/actions-global": "21.21.0",
"@commercetools-frontend/application-components": "21.21.0",
"@commercetools-frontend/application-config": "21.21.0",
"@commercetools-frontend/application-shell-connectors": "21.21.0",
"@commercetools-frontend/assets": "21.21.0",
"@commercetools-frontend/browser-history": "21.21.0",
"@commercetools-frontend/constants": "21.21.0",
"@commercetools-frontend/i18n": "21.21.0",
"@commercetools-frontend/l10n": "21.21.0",
"@commercetools-frontend/notifications": "21.21.0",
"@commercetools-frontend/permissions": "21.21.0",
"@commercetools-frontend/react-notifications": "21.21.0",
"@commercetools-frontend/sdk": "21.21.0",
"@commercetools-frontend/sentry": "21.21.0",
"@commercetools-frontend/url-utils": "21.21.0",
"@commercetools-frontend/actions-global": "workspace:*",
"@commercetools-frontend/application-components": "workspace:*",
"@commercetools-frontend/application-config": "workspace:*",
"@commercetools-frontend/application-shell-connectors": "workspace:*",
"@commercetools-frontend/assets": "workspace:*",
"@commercetools-frontend/browser-history": "workspace:*",
"@commercetools-frontend/constants": "workspace:*",
"@commercetools-frontend/i18n": "workspace:*",
"@commercetools-frontend/l10n": "workspace:*",
"@commercetools-frontend/notifications": "workspace:*",
"@commercetools-frontend/permissions": "workspace:*",
"@commercetools-frontend/react-notifications": "workspace:*",
"@commercetools-frontend/sdk": "workspace:*",
"@commercetools-frontend/sentry": "workspace:*",
"@commercetools-frontend/url-utils": "workspace:*",
"@commercetools-uikit/accessible-hidden": "^15.6.0",
"@commercetools-uikit/avatar": "^15.6.0",
"@commercetools-uikit/card": "^15.6.0",
Expand Down
7 changes: 5 additions & 2 deletions packages/create-mc-app/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Listr, type ListrTask } from 'listr2';
import * as tasks from './tasks';
import { throwIfNodeVersionIsNotSupported } from './validations';
import { shouldUseYarn } from './utils';
import getLatestReleaseVersion from './get-latest-release-version';
import hintOutdatedVersion from './hint-outdated-version';
import processOptions from './process-options';
import type { TCliCommandOptions } from './types';
Expand Down Expand Up @@ -60,7 +61,9 @@ const run = () => {
return;
}

await hintOutdatedVersion(pkgJson.version);
const releaseVersion = await getLatestReleaseVersion();

hintOutdatedVersion(pkgJson.version, releaseVersion);

console.log('');
console.log(
Expand All @@ -73,7 +76,7 @@ const run = () => {
const taskList = new Listr(
[
tasks.downloadTemplate(taskOptions),
tasks.updatePackageJson(taskOptions),
tasks.updatePackageJson(taskOptions, releaseVersion),
tasks.updateCustomApplicationConfig(taskOptions),
tasks.updateApplicationConstants(taskOptions),
!options.skipInstall && tasks.installDependencies(taskOptions),
Expand Down
15 changes: 15 additions & 0 deletions packages/create-mc-app/src/get-latest-release-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import execa from 'execa';

async function getLatestReleaseVersion() {
const commandResult = await execa.command(
'npm view @commercetools-frontend/create-mc-app --json',
{ encoding: 'utf-8' }
);

const packageInfoForTagLatest = JSON.parse(commandResult.stdout) as {
version: string;
};
return packageInfoForTagLatest.version;
}

export default getLatestReleaseVersion;
40 changes: 10 additions & 30 deletions packages/create-mc-app/src/hint-outdated-version.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,18 @@
import semver from 'semver';
import execa from 'execa';

async function hintOutdatedVersion(currentVersion: string) {
try {
const commandResult = await execa.command(
'npm view @commercetools-frontend/create-mc-app --json',
{ encoding: 'utf-8' }
);
function hintOutdatedVersion(currentVersion: string, releaseVersion: string) {
const hasBeenReleastedInLatestTag = semver.gt(releaseVersion, currentVersion);

const packageInfoForTagLatest = JSON.parse(commandResult.stdout);
const hintNewerVersions = [hasBeenReleastedInLatestTag && `${releaseVersion}`]
.filter(Boolean)
.join(', ');

const hasBeenReleastedInLatestTag = semver.gt(
packageInfoForTagLatest.version,
currentVersion
if (hintNewerVersions.length > 0) {
console.log('');
console.log(
`New version available! ${currentVersion} -> ${hintNewerVersions}`
);

const hintNewerVersions = [
hasBeenReleastedInLatestTag && `${packageInfoForTagLatest.version}`,
]
.filter(Boolean)
.join(', ');

if (hintNewerVersions.length > 0) {
console.log('');
console.log(
`New version available! ${currentVersion} -> ${hintNewerVersions}`
);
console.log('');
}
} catch (error) {
// Ignore errors, as this function should not affect the exit code of the command
if (process.env.NODE_ENV === 'test') {
console.error(error);
}
console.log('');
}
}

Expand Down
Loading

1 comment on commit e3ffe6c

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for merchant-center-application-kit ready!

✅ Preview
https://merchant-center-application-897hmihqa-commercetools.vercel.app

Built with commit e3ffe6c.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.