1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix windows not being able to build new Feature packages (#7220)

* Add missing dev script

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Inline all shared scripts to make them work in all environments

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Switch to using deterministic fake for path.join in unit test

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Make multi export config for webpack not fail when used in windows

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

---------

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2023-02-23 10:54:35 +02:00 committed by GitHub
parent f212c90b1a
commit a7181047d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 20 additions and 27 deletions

7
package-lock.json generated
View File

@ -32832,9 +32832,6 @@
"jest-watch-typeahead": "^2.2.1", "jest-watch-typeahead": "^2.2.1",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"ts-jest": "^29.0.3" "ts-jest": "^29.0.3"
},
"bin": {
"lens-test": "bin/test.sh"
} }
}, },
"packages/infrastructure/jest/node_modules/@jest/console": { "packages/infrastructure/jest/node_modules/@jest/console": {
@ -34112,10 +34109,6 @@
"webpack": "^5.75.0", "webpack": "^5.75.0",
"webpack-cli": "^4.10.0", "webpack-cli": "^4.10.0",
"webpack-node-externals": "^3.0.0" "webpack-node-externals": "^3.0.0"
},
"bin": {
"lens-build": "bin/build.sh",
"lens-remove-build": "bin/remove-build.sh"
} }
}, },
"packages/infrastructure/webpack/node_modules/sass-loader": { "packages/infrastructure/webpack/node_modules/sass-loader": {

View File

@ -15,9 +15,6 @@
}, },
"license": "MIT", "license": "MIT",
"homepage": "https://github.com/lensapp/lens", "homepage": "https://github.com/lensapp/lens",
"bin": {
"lens-test": "bin/test.sh"
},
"dependencies": { "dependencies": {
"@swc/core": "^1.3.20", "@swc/core": "^1.3.20",
"@swc/jest": "^0.2.23", "@swc/jest": "^0.2.23",

View File

@ -1,2 +0,0 @@
set -e
webpack $@

View File

@ -1 +0,0 @@
rm -rfv build

View File

@ -15,12 +15,8 @@
}, },
"license": "MIT", "license": "MIT",
"homepage": "https://github.com/lensapp/lens", "homepage": "https://github.com/lensapp/lens",
"bin": {
"lens-build": "bin/build.sh",
"lens-remove-build": "bin/remove-build.sh"
},
"scripts": { "scripts": {
"test:unit": "lens-test" "test:unit": "jest --coverage --runInBand"
}, },
"dependencies": { "dependencies": {
"@types/webpack-env": "^1.18.0", "@types/webpack-env": "^1.18.0",

View File

@ -14,7 +14,7 @@ const {
} = require("lodash/fp"); } = require("lodash/fp");
const { pipeline } = require("@ogre-tools/fp"); const { pipeline } = require("@ogre-tools/fp");
module.exports = (packageJson, dependencies = { nodeConfig, reactConfig }) => { module.exports = (packageJson, dependencies = { nodeConfig, reactConfig, joinPath: path.join }) => {
if (!packageJson.lensMultiExportConfig) { if (!packageJson.lensMultiExportConfig) {
throw new Error( throw new Error(
`Tried to get multi export config for package "${packageJson.name}" but configuration is missing.` `Tried to get multi export config for package "${packageJson.name}" but configuration is missing.`
@ -80,7 +80,9 @@ module.exports = (packageJson, dependencies = { nodeConfig, reactConfig }) => {
}; };
const toExpectedExport = (externalImportPath) => { const toExpectedExport = (externalImportPath) => {
const entrypointPath = `./${path.join( const posixJoinForPackageJson = path.posix.join;
const entrypointPath = `./${posixJoinForPackageJson(
"./dist", "./dist",
externalImportPath, externalImportPath,
"index.js" "index.js"
@ -89,7 +91,7 @@ const toExpectedExport = (externalImportPath) => {
return [ return [
externalImportPath, externalImportPath,
{ {
types: `./${path.join("./dist", externalImportPath, "index.d.ts")}`, types: `./${posixJoinForPackageJson("./dist", externalImportPath, "index.d.ts")}`,
default: entrypointPath, default: entrypointPath,
import: entrypointPath, import: entrypointPath,
@ -114,7 +116,7 @@ const toExportSpecificWebpackConfigFor =
output: { output: {
...baseConfig.output, ...baseConfig.output,
path: path.join(baseConfig.output.path, externalImportPath), path: dependencies.joinPath(baseConfig.output.path, externalImportPath),
}, },
}; };
}; };

View File

@ -1,4 +1,7 @@
import getMultiExportConfig from "./get-multi-export-config"; import getMultiExportConfig from "./get-multi-export-config";
import path from 'path';
const joinPathFake = path.posix.join;
describe("get-multi-export-config", () => { describe("get-multi-export-config", () => {
let actual; let actual;
@ -52,6 +55,7 @@ describe("get-multi-export-config", () => {
actual = getMultiExportConfig(maximalPackageJson, { actual = getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub, nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub, reactConfig: reactConfigStub,
joinPath: joinPathFake,
}); });
expect(actual).toEqual([ expect(actual).toEqual([
@ -93,6 +97,7 @@ describe("get-multi-export-config", () => {
getMultiExportConfig(maximalPackageJson, { getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub, nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub, reactConfig: reactConfigStub,
joinPath: joinPathFake,
}); });
}).toThrow( }).toThrow(
'Tried to get multi export config but exports of package.json for "some-name" did not match exactly:' 'Tried to get multi export config but exports of package.json for "some-name" did not match exactly:'
@ -106,6 +111,7 @@ describe("get-multi-export-config", () => {
getMultiExportConfig(maximalPackageJson, { getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub, nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub, reactConfig: reactConfigStub,
joinPath: joinPathFake,
}); });
}).toThrow( }).toThrow(
'Tried to get multi export config but exports of package.json for "some-name" did not match exactly:' 'Tried to get multi export config but exports of package.json for "some-name" did not match exactly:'
@ -119,6 +125,7 @@ describe("get-multi-export-config", () => {
getMultiExportConfig(maximalPackageJson, { getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub, nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub, reactConfig: reactConfigStub,
joinPath: joinPathFake,
}); });
}).toThrow( }).toThrow(
'Tried to get multi export config but exports of package.json for "some-name" did not match exactly:' 'Tried to get multi export config but exports of package.json for "some-name" did not match exactly:'
@ -132,6 +139,7 @@ describe("get-multi-export-config", () => {
getMultiExportConfig(maximalPackageJson, { getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub, nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub, reactConfig: reactConfigStub,
joinPath: joinPathFake,
}); });
}).toThrow( }).toThrow(
'Tried to get multi export config for package "some-name" but configuration is missing.' 'Tried to get multi export config for package "some-name" but configuration is missing.'
@ -145,6 +153,7 @@ describe("get-multi-export-config", () => {
getMultiExportConfig(maximalPackageJson, { getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub, nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub, reactConfig: reactConfigStub,
joinPath: joinPathFake,
}); });
}).toThrow( }).toThrow(
'Tried to get multi export config for package "some-name" but build types "some-invalid" were not any of "node", "react".' 'Tried to get multi export config for package "some-name" but build types "some-invalid" were not any of "node", "react".'
@ -159,6 +168,7 @@ describe("get-multi-export-config", () => {
getMultiExportConfig(maximalPackageJson, { getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub, nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub, reactConfig: reactConfigStub,
joinPath: joinPathFake,
}); });
}).toThrow( }).toThrow(
'Tried to get multi export config for package "some-name" but entrypoint was missing for "./some-entrypoint".' 'Tried to get multi export config for package "some-name" but entrypoint was missing for "./some-entrypoint".'

View File

@ -20,11 +20,9 @@
"license": "MIT", "license": "MIT",
"homepage": "https://github.com/lensapp/lens", "homepage": "https://github.com/lensapp/lens",
"scripts": { "scripts": {
"build": "lens-build", "build": "webpack",
"build:remove": "lens-remove-build", "dev": "webpack --mode=development --watch",
"code-style:fix": "lens-fix-code-style", "test": "jest --coverage --runInBand"
"code-style:verify": "lens-verify-code-style",
"test": "lens-test"
}, },
"peerDependencies": { "peerDependencies": {
"@ogre-tools/fp": "^12.0.1", "@ogre-tools/fp": "^12.0.1",