Skip to content

Commit

Permalink
Create placeholders for relocating Source NPM packages to DCR (#11496)
Browse files Browse the repository at this point in the history
* add placeholders for relocating Source NPM packages to dcr

* aw jest you’re so cute

provide commonjs versions of placeholder packages for Jest

* permit `workspace` deps in `package.json`

* package names don’t need a scope

it’s not a real scope anyway, it’s not adding anything
  • Loading branch information
sndrs authored Jun 10, 2024
1 parent 4b8777a commit 076ffac
Show file tree
Hide file tree
Showing 18 changed files with 167 additions and 70 deletions.
4 changes: 2 additions & 2 deletions apps-rendering/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"@guardian/eslint-config-typescript": "9.0.1",
"@guardian/libs": "16.1.0",
"@guardian/renditions": "0.2.0",
"@guardian/source": "1.0.0",
"@guardian/source-development-kitchen": "1.0.0",
"@guardian/source": "workspace:*",
"@guardian/source-development-kitchen": "workspace:*",
"@smithy/property-provider": "2.0.16",
"@storybook/addon-essentials": "7.6.18",
"@storybook/addons": "7.6.18",
Expand Down
4 changes: 2 additions & 2 deletions dotcom-rendering/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"@guardian/libs": "16.1.0",
"@guardian/ophan-tracker-js": "2.1.1",
"@guardian/shimport": "1.0.2",
"@guardian/source": "1.0.1",
"@guardian/source-development-kitchen": "1.0.0",
"@guardian/source": "workspace:*",
"@guardian/source-development-kitchen": "workspace:*",
"@guardian/support-dotcom-components": "2.3.3",
"@guardian/tsconfig": "0.2.0",
"@playwright/test": "1.40.1",
Expand Down
3 changes: 2 additions & 1 deletion dotcom-rendering/scripts/env/check-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ if (pkg.devDependencies) {
}

const mismatches = Object.entries(pkg.dependencies).filter(
([, version]) => !semver.valid(version),
([, version]) =>
!semver.valid(version) && !version.startsWith('workspace:'),
);

if (mismatches.length !== 0) {
Expand Down
7 changes: 7 additions & 0 deletions libs/@guardian/source-development-kitchen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @guardian/source-development-kitchen

This is temporary placeholder for the real source code that we hope to move here from CSNX.

For now, it simply re-exports the NPM package, which is still published from CSNX.

The actual source code still lives in https://github.com/guardian/csnx/tree/main/libs/%40guardian/source-development-kitchen (for now).
25 changes: 25 additions & 0 deletions libs/@guardian/source-development-kitchen/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@guardian/source-development-kitchen",
"private": true,
"sideEffects": false,
"type": "module",
"exports": {
"./react-components": {
"types": "./react-components.d.ts",
"import": "./react-components.js",
"require": "./react-components.cjs"
}
},
"dependencies": {
"CSNX_SOURCE_DEVELOPMENT_KITCHEN": "npm:@guardian/[email protected]"
},
"peerDependencies": {
"@emotion/react": "^11.11.1",
"@guardian/libs": "^16.0.0",
"@guardian/source": "^1.0.0",
"@types/react": "^18.2.11",
"react": "^18.2.0",
"tslib": "^2.6.2",
"typescript": "~5.3.3"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const reactComponents = require('CSNX_SOURCE_DEVELOPMENT_KITCHEN/react-components');

for (const key in reactComponents) {
if (reactComponents.hasOwnProperty(key)) {
exports[key] = reactComponents[key];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from 'CSNX_SOURCE_DEVELOPMENT_KITCHEN/react-components';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from 'CSNX_SOURCE_DEVELOPMENT_KITCHEN/react-components';
7 changes: 7 additions & 0 deletions libs/@guardian/source/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @guardian/source

This is temporary placeholder for the real source code that we hope to move here from CSNX.

For now, it simply re-exports the NPM package, which is still published from CSNX.

The actual source code still lives in https://github.com/guardian/csnx/tree/main/libs/%40guardian/source (for now).
7 changes: 7 additions & 0 deletions libs/@guardian/source/foundations.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const foundations = require('CSNX_SOURCE/foundations');

for (const key in foundations) {
if (foundations.hasOwnProperty(key)) {
exports[key] = foundations[key];
}
}
1 change: 1 addition & 0 deletions libs/@guardian/source/foundations.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from 'CSNX_SOURCE/foundations';
1 change: 1 addition & 0 deletions libs/@guardian/source/foundations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from 'CSNX_SOURCE/foundations';
28 changes: 28 additions & 0 deletions libs/@guardian/source/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@guardian/source",
"private": true,
"sideEffects": false,
"type": "module",
"exports": {
"./foundations": {
"types": "./foundations.d.ts",
"import": "./foundations.js",
"require": "./foundations.cjs"
},
"./react-components": {
"types": "./react-components.d.ts",
"import": "./react-components.js",
"require": "./react-components.cjs"
}
},
"dependencies": {
"CSNX_SOURCE": "npm:@guardian/[email protected]"
},
"peerDependencies": {
"@emotion/react": "^11.11.1",
"@types/react": "^18.2.11",
"react": "^18.2.0",
"tslib": "^2.6.2",
"typescript": "~5.3.3"
}
}
7 changes: 7 additions & 0 deletions libs/@guardian/source/react-components.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const reactComponents = require('CSNX_SOURCE/react-components');

for (const key in reactComponents) {
if (reactComponents.hasOwnProperty(key)) {
exports[key] = reactComponents[key];
}
}
1 change: 1 addition & 0 deletions libs/@guardian/source/react-components.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from 'CSNX_SOURCE/react-components';
1 change: 1 addition & 0 deletions libs/@guardian/source/react-components.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from 'CSNX_SOURCE/react-components';
131 changes: 66 additions & 65 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
packages:
- 'apps-rendering'
- 'dotcom-rendering'
- 'libs/**'

0 comments on commit 076ffac

Please sign in to comment.