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:
1 parent
df0f080380
commit
f2a3710d04
32 files changed
+17913
-21704
No files matched your search
@@ -15,4 +15,5 @@ src/extensions/*/*.d.ts
|
||||
types/extension-api.d.ts
|
||||
types/extension-renderer-api.d.ts
|
||||
extensions/*/dist
|
||||
extensions/*/package-lock.json
|
||||
docs/extensions/api
|
||||
@@ -56,10 +56,10 @@ else
|
||||
endif
|
||||
|
||||
build-extensions:
|
||||
$(foreach dir, $(wildcard $(EXTENSIONS_DIR)/*), $(MAKE) -C $(dir) build || exit $?; )
|
||||
yarn intree-extensions $(EXTENSIONS_DIR) build
|
||||
|
||||
test-extensions:
|
||||
$(foreach dir, $(wildcard $(EXTENSIONS_DIR)/*), $(MAKE) -C $(dir) test || exit $?; )
|
||||
yarn intree-extensions $(EXTENSIONS_DIR) test
|
||||
|
||||
build-npm: build-extension-types
|
||||
yarn npm:fix-package-version
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
install-deps:
|
||||
yarn install
|
||||
|
||||
build: install-deps
|
||||
yarn run build
|
||||
|
||||
test:
|
||||
yarn run test
|
||||
-3468
File diff suppressed because it is too large.
Load diff
@@ -11,7 +11,7 @@
|
||||
"scripts": {
|
||||
"build": "webpack --config webpack.config.js",
|
||||
"dev": "npm run build --watch",
|
||||
"test": "echo NO TESTS"
|
||||
"test": "jest --passWithNoTests --env=jsdom src $@"
|
||||
},
|
||||
"dependencies": {
|
||||
"react-open-doodles": "^1.0.5"
|
||||
|
||||
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
File diff suppressed because it is too large.
Load diff
@@ -6,7 +6,7 @@
|
||||
"scripts": {
|
||||
"build": "webpack -p",
|
||||
"dev": "webpack --watch",
|
||||
"test": "echo NO TESTS"
|
||||
"test": "jest --passWithNoTests --env=jsdom src $@"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
|
||||
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
File diff suppressed because it is too large.
Load diff
@@ -10,7 +10,7 @@
|
||||
"scripts": {
|
||||
"build": "webpack --config webpack.config.js",
|
||||
"dev": "npm run build --watch",
|
||||
"test": "echo NO TESTS"
|
||||
"test": "jest --passWithNoTests --env=jsdom src $@"
|
||||
},
|
||||
"dependencies": {
|
||||
"semver": "^7.3.2"
|
||||
|
||||
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
|
||||
Generated
-3512
File diff suppressed because it is too large.
Load diff
@@ -10,7 +10,7 @@
|
||||
"scripts": {
|
||||
"build": "webpack --config webpack.config.js",
|
||||
"dev": "npm run build --watch",
|
||||
"test": "echo NO TESTS"
|
||||
"test": "jest --passWithNoTests --env=jsdom src $@"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
|
||||
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
|
||||
Generated
-3512
File diff suppressed because it is too large.
Load diff
@@ -10,7 +10,7 @@
|
||||
"scripts": {
|
||||
"build": "webpack --config webpack.config.js",
|
||||
"dev": "npm run build --watch",
|
||||
"test": "echo NO TESTS"
|
||||
"test": "jest --passWithNoTests --env=jsdom src $@"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
|
||||
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": {
|
||||
"build": "webpack -p",
|
||||
"dev": "webpack --watch",
|
||||
"test": "echo NO TESTS"
|
||||
"test": "jest --passWithNoTests --env=jsdom src $@"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
|
||||
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
|
||||
Generated
-3984
File diff suppressed because it is too large.
Load diff
@@ -11,7 +11,7 @@
|
||||
"scripts": {
|
||||
"build": "webpack -p",
|
||||
"dev": "webpack --watch",
|
||||
"test": "echo NO TESTS"
|
||||
"test": "jest --passWithNoTests --env=jsdom src $@"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -23,6 +23,7 @@
|
||||
"compile:i18n": "lingui compile",
|
||||
"compile:extension-types": "rollup --config src/extensions/rollup.config.js",
|
||||
"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:mac": "yarn compile && electron-builder --mac --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-notarize": "^0.3.0",
|
||||
"eslint": "^7.7.0",
|
||||
"execa": "^4.1.0",
|
||||
"file-loader": "^6.0.0",
|
||||
"flex.box": "^3.4.4",
|
||||
"fork-ts-checker-webpack-plugin": "^5.0.0",
|
||||
|
||||
@@ -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)
|
||||
@@ -6026,6 +6026,21 @@ execa@^4.0.0:
|
||||
signal-exit "^3.0.2"
|
||||
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:
|
||||
version "0.1.2"
|
||||
resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c"
|
||||
|
||||
Reference in new issue
Block a user