mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Remove Makefile from all intree extensions
- Makefiles are not really common (rightly so) in JS projects and script entries in the package.json are good enough and what they're there for. - Move to using yarn for installing dependencies and running scripts as that is what we mostly use for the rest of the project. - Move from using make syntax to a dedicated script for building and testing extensions. Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
df0f080380
commit
f2a3710d04
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,4 +15,5 @@ src/extensions/*/*.d.ts
|
|||||||
types/extension-api.d.ts
|
types/extension-api.d.ts
|
||||||
types/extension-renderer-api.d.ts
|
types/extension-renderer-api.d.ts
|
||||||
extensions/*/dist
|
extensions/*/dist
|
||||||
|
extensions/*/package-lock.json
|
||||||
docs/extensions/api
|
docs/extensions/api
|
||||||
4
Makefile
4
Makefile
@ -56,10 +56,10 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
build-extensions:
|
build-extensions:
|
||||||
$(foreach dir, $(wildcard $(EXTENSIONS_DIR)/*), $(MAKE) -C $(dir) build || exit $?; )
|
yarn intree-extensions $(EXTENSIONS_DIR) build
|
||||||
|
|
||||||
test-extensions:
|
test-extensions:
|
||||||
$(foreach dir, $(wildcard $(EXTENSIONS_DIR)/*), $(MAKE) -C $(dir) test || exit $?; )
|
yarn intree-extensions $(EXTENSIONS_DIR) test
|
||||||
|
|
||||||
build-npm: build-extension-types
|
build-npm: build-extension-types
|
||||||
yarn npm:fix-package-version
|
yarn npm:fix-package-version
|
||||||
|
|||||||
@ -1,8 +0,0 @@
|
|||||||
install-deps:
|
|
||||||
yarn install
|
|
||||||
|
|
||||||
build: install-deps
|
|
||||||
yarn run build
|
|
||||||
|
|
||||||
test:
|
|
||||||
yarn run test
|
|
||||||
3468
extensions/example-extension/package-lock.json
generated
3468
extensions/example-extension/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -11,7 +11,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack --config webpack.config.js",
|
"build": "webpack --config webpack.config.js",
|
||||||
"dev": "npm run build --watch",
|
"dev": "npm run build --watch",
|
||||||
"test": "echo NO TESTS"
|
"test": "jest --passWithNoTests --env=jsdom src $@"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"react-open-doodles": "^1.0.5"
|
"react-open-doodles": "^1.0.5"
|
||||||
|
|||||||
2402
extensions/example-extension/yarn.lock
Normal file
2402
extensions/example-extension/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,8 +0,0 @@
|
|||||||
install-deps:
|
|
||||||
yarn install
|
|
||||||
|
|
||||||
build: install-deps
|
|
||||||
yarn run build
|
|
||||||
|
|
||||||
test:
|
|
||||||
yarn run test
|
|
||||||
3589
extensions/license-menu-item/package-lock.json
generated
3589
extensions/license-menu-item/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack -p",
|
"build": "webpack -p",
|
||||||
"dev": "webpack --watch",
|
"dev": "webpack --watch",
|
||||||
"test": "echo NO TESTS"
|
"test": "jest --passWithNoTests --env=jsdom src $@"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
2521
extensions/license-menu-item/yarn.lock
Normal file
2521
extensions/license-menu-item/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,8 +0,0 @@
|
|||||||
install-deps:
|
|
||||||
yarn install
|
|
||||||
|
|
||||||
build: install-deps
|
|
||||||
yarn run build
|
|
||||||
|
|
||||||
test:
|
|
||||||
yarn run test
|
|
||||||
3574
extensions/metrics-cluster-feature/package-lock.json
generated
3574
extensions/metrics-cluster-feature/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -10,7 +10,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack --config webpack.config.js",
|
"build": "webpack --config webpack.config.js",
|
||||||
"dev": "npm run build --watch",
|
"dev": "npm run build --watch",
|
||||||
"test": "echo NO TESTS"
|
"test": "jest --passWithNoTests --env=jsdom src $@"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"semver": "^7.3.2"
|
"semver": "^7.3.2"
|
||||||
|
|||||||
2442
extensions/metrics-cluster-feature/yarn.lock
Normal file
2442
extensions/metrics-cluster-feature/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,8 +0,0 @@
|
|||||||
install-deps:
|
|
||||||
yarn install
|
|
||||||
|
|
||||||
build: install-deps
|
|
||||||
yarn run build
|
|
||||||
|
|
||||||
test:
|
|
||||||
yarn run test
|
|
||||||
3512
extensions/node-menu/package-lock.json
generated
3512
extensions/node-menu/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -10,7 +10,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack --config webpack.config.js",
|
"build": "webpack --config webpack.config.js",
|
||||||
"dev": "npm run build --watch",
|
"dev": "npm run build --watch",
|
||||||
"test": "echo NO TESTS"
|
"test": "jest --passWithNoTests --env=jsdom src $@"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
2437
extensions/node-menu/yarn.lock
Normal file
2437
extensions/node-menu/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,8 +0,0 @@
|
|||||||
install-deps:
|
|
||||||
yarn install
|
|
||||||
|
|
||||||
build: install-deps
|
|
||||||
yarn run build
|
|
||||||
|
|
||||||
test:
|
|
||||||
yarn run test
|
|
||||||
3512
extensions/pod-menu/package-lock.json
generated
3512
extensions/pod-menu/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -10,7 +10,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack --config webpack.config.js",
|
"build": "webpack --config webpack.config.js",
|
||||||
"dev": "npm run build --watch",
|
"dev": "npm run build --watch",
|
||||||
"test": "echo NO TESTS"
|
"test": "jest --passWithNoTests --env=jsdom src $@"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
2437
extensions/pod-menu/yarn.lock
Normal file
2437
extensions/pod-menu/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,8 +0,0 @@
|
|||||||
install-deps:
|
|
||||||
yarn install
|
|
||||||
|
|
||||||
build: install-deps
|
|
||||||
yarn run build
|
|
||||||
|
|
||||||
test:
|
|
||||||
yarn run test
|
|
||||||
@ -7,7 +7,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack -p",
|
"build": "webpack -p",
|
||||||
"dev": "webpack --watch",
|
"dev": "webpack --watch",
|
||||||
"test": "echo NO TESTS"
|
"test": "jest --passWithNoTests --env=jsdom src $@"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
2725
extensions/support-page/yarn.lock
Normal file
2725
extensions/support-page/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,8 +0,0 @@
|
|||||||
install-deps:
|
|
||||||
yarn install
|
|
||||||
|
|
||||||
build: install-deps
|
|
||||||
yarn run build
|
|
||||||
|
|
||||||
test:
|
|
||||||
yarn run test
|
|
||||||
3984
extensions/telemetry/package-lock.json
generated
3984
extensions/telemetry/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -11,7 +11,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack -p",
|
"build": "webpack -p",
|
||||||
"dev": "webpack --watch",
|
"dev": "webpack --watch",
|
||||||
"test": "echo NO TESTS"
|
"test": "jest --passWithNoTests --env=jsdom src $@"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
2828
extensions/telemetry/yarn.lock
Normal file
2828
extensions/telemetry/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@ -23,6 +23,7 @@
|
|||||||
"compile:i18n": "lingui compile",
|
"compile:i18n": "lingui compile",
|
||||||
"compile:extension-types": "rollup --config src/extensions/rollup.config.js",
|
"compile:extension-types": "rollup --config src/extensions/rollup.config.js",
|
||||||
"npm:fix-package-version": "ts-node build/set_npm_version.ts",
|
"npm:fix-package-version": "ts-node build/set_npm_version.ts",
|
||||||
|
"intree-extensions": "ts-node scripts/intree-extensions.ts",
|
||||||
"build:linux": "yarn compile && electron-builder --linux --dir -c.productName=Lens",
|
"build:linux": "yarn compile && electron-builder --linux --dir -c.productName=Lens",
|
||||||
"build:mac": "yarn compile && electron-builder --mac --dir -c.productName=Lens",
|
"build:mac": "yarn compile && electron-builder --mac --dir -c.productName=Lens",
|
||||||
"build:win": "yarn compile && electron-builder --win --dir -c.productName=Lens",
|
"build:win": "yarn compile && electron-builder --win --dir -c.productName=Lens",
|
||||||
@ -340,6 +341,7 @@
|
|||||||
"electron-builder": "^22.7.0",
|
"electron-builder": "^22.7.0",
|
||||||
"electron-notarize": "^0.3.0",
|
"electron-notarize": "^0.3.0",
|
||||||
"eslint": "^7.7.0",
|
"eslint": "^7.7.0",
|
||||||
|
"execa": "^4.1.0",
|
||||||
"file-loader": "^6.0.0",
|
"file-loader": "^6.0.0",
|
||||||
"flex.box": "^3.4.4",
|
"flex.box": "^3.4.4",
|
||||||
"fork-ts-checker-webpack-plugin": "^5.0.0",
|
"fork-ts-checker-webpack-plugin": "^5.0.0",
|
||||||
|
|||||||
94
scripts/intree-extensions.ts
Normal file
94
scripts/intree-extensions.ts
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
import path from "path"
|
||||||
|
import fse from "fs-extra"
|
||||||
|
import execa from "execa"
|
||||||
|
import { Writable } from "stream"
|
||||||
|
|
||||||
|
function firstLongest(a: string, b: string) {
|
||||||
|
if (a.length >= b.length) {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeSink(prefix: string) {
|
||||||
|
let buf = ""
|
||||||
|
|
||||||
|
return new Writable({
|
||||||
|
write(chunk: any, encoding: string, cb: () => void) {
|
||||||
|
buf += chunk
|
||||||
|
|
||||||
|
const parts = buf.split(/\r?\n/)
|
||||||
|
const endsWithNL = buf.endsWith("\n")
|
||||||
|
if (endsWithNL) {
|
||||||
|
buf = parts.pop()
|
||||||
|
} else {
|
||||||
|
buf = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const line of parts) {
|
||||||
|
console.log(`${prefix}${line}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
cb()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const args = process.argv.slice(2) // remove node call and file name call
|
||||||
|
|
||||||
|
async function buildInTreeExtension(extensionPath: string, prefix: string) {
|
||||||
|
console.log(`Building: ${extensionPath}`)
|
||||||
|
|
||||||
|
const install = execa("yarn", { cwd: extensionPath })
|
||||||
|
install.stdout.pipe(makeSink(prefix))
|
||||||
|
await install
|
||||||
|
|
||||||
|
const build = execa("yarn", ["run", "build"], { cwd: extensionPath })
|
||||||
|
build.stdout.pipe(makeSink(prefix))
|
||||||
|
await build
|
||||||
|
}
|
||||||
|
|
||||||
|
async function testInTreeExtension(extensionPath: string, prefix: string) {
|
||||||
|
console.log(`Testing: ${extensionPath}`)
|
||||||
|
|
||||||
|
const test = execa("yarn", ["test"], { cwd: extensionPath })
|
||||||
|
test.stdout.pipe(makeSink(prefix))
|
||||||
|
await test
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const cwd = process.cwd()
|
||||||
|
const [extensionsFolder, action] = args
|
||||||
|
const pathToRootExtensions = path.resolve(path.join(cwd, extensionsFolder))
|
||||||
|
|
||||||
|
const folders: string[] = []
|
||||||
|
const names: string[] = []
|
||||||
|
|
||||||
|
for (const entry of await fse.readdir(pathToRootExtensions)) {
|
||||||
|
const entryPath = path.resolve(pathToRootExtensions, entry)
|
||||||
|
const info = await fse.stat(entryPath)
|
||||||
|
if (!info.isDirectory()) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
folders.push(entryPath)
|
||||||
|
names.push(entry)
|
||||||
|
}
|
||||||
|
|
||||||
|
const longestName = names.reduce(firstLongest, "")
|
||||||
|
const prefixWidth = longestName.length + 1
|
||||||
|
const prefixes = names.map(name => `${name}:${" ".repeat(prefixWidth - name.length)}`)
|
||||||
|
|
||||||
|
switch (action.toLowerCase()) {
|
||||||
|
case "build":
|
||||||
|
await Promise.all(folders.map((folder, i) => buildInTreeExtension(folder, prefixes[i])))
|
||||||
|
break
|
||||||
|
case "test":
|
||||||
|
await Promise.all(folders.map((folder, i) => testInTreeExtension(folder, prefixes[i])))
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch(console.error)
|
||||||
15
yarn.lock
15
yarn.lock
@ -6026,6 +6026,21 @@ execa@^4.0.0:
|
|||||||
signal-exit "^3.0.2"
|
signal-exit "^3.0.2"
|
||||||
strip-final-newline "^2.0.0"
|
strip-final-newline "^2.0.0"
|
||||||
|
|
||||||
|
execa@^4.1.0:
|
||||||
|
version "4.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/execa/-/execa-4.1.0.tgz#4e5491ad1572f2f17a77d388c6c857135b22847a"
|
||||||
|
integrity sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA==
|
||||||
|
dependencies:
|
||||||
|
cross-spawn "^7.0.0"
|
||||||
|
get-stream "^5.0.0"
|
||||||
|
human-signals "^1.1.1"
|
||||||
|
is-stream "^2.0.0"
|
||||||
|
merge-stream "^2.0.0"
|
||||||
|
npm-run-path "^4.0.0"
|
||||||
|
onetime "^5.1.0"
|
||||||
|
signal-exit "^3.0.2"
|
||||||
|
strip-final-newline "^2.0.0"
|
||||||
|
|
||||||
exit@^0.1.2:
|
exit@^0.1.2:
|
||||||
version "0.1.2"
|
version "0.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c"
|
resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user