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

add jest as extension devDep, go back to using makefile foreach syntax

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2020-11-12 09:37:18 -05:00
parent f2a3710d04
commit 9f25260160
17 changed files with 18176 additions and 232 deletions

View File

@ -56,10 +56,10 @@ else
endif
build-extensions:
yarn intree-extensions $(EXTENSIONS_DIR) build
$(foreach dir, $(wildcard $(EXTENSIONS_DIR)/*), cd $(dir) && npm install && npm build;)
test-extensions:
yarn intree-extensions $(EXTENSIONS_DIR) test
$(foreach dir, $(wildcard $(EXTENSIONS_DIR)/*), cd $(dir) && npm test;)
build-npm: build-extension-types
yarn npm:fix-package-version

View File

@ -18,6 +18,7 @@
},
"devDependencies": {
"@k8slens/extensions": "file:../../src/extensions/npm/extensions",
"jest": "^26.6.3",
"ts-loader": "^8.0.4",
"typescript": "^4.0.3",
"webpack": "^4.44.2"

File diff suppressed because it is too large Load Diff

View File

@ -10,8 +10,9 @@
},
"dependencies": {},
"devDependencies": {
"@types/webpack": "^4.41.17",
"@k8slens/extensions": "file:../../src/extensions/npm/extensions",
"@types/webpack": "^4.41.17",
"jest": "^26.6.3",
"mobx": "^5.15.5",
"react": "^16.13.1",
"ts-loader": "^8.0.4",

File diff suppressed because it is too large Load Diff

View File

@ -17,10 +17,11 @@
},
"devDependencies": {
"@k8slens/extensions": "file:../../src/extensions/npm/extensions",
"jest": "^26.6.3",
"mobx": "^5.15.5",
"react": "^16.13.1",
"ts-loader": "^8.0.4",
"typescript": "^4.0.3",
"webpack": "^4.44.2",
"mobx": "^5.15.5",
"react": "^16.13.1"
"webpack": "^4.44.2"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -15,10 +15,11 @@
"dependencies": {},
"devDependencies": {
"@k8slens/extensions": "file:../../src/extensions/npm/extensions",
"jest": "^26.6.3",
"mobx": "^5.15.5",
"react": "^16.13.1",
"ts-loader": "^8.0.4",
"typescript": "^4.0.3",
"webpack": "^4.44.2",
"mobx": "^5.15.5",
"react": "^16.13.1"
"webpack": "^4.44.2"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -14,11 +14,12 @@
},
"dependencies": {},
"devDependencies": {
"ts-loader": "^8.0.4",
"typescript": "^4.0.3",
"webpack": "^4.44.2",
"@k8slens/extensions": "file:../../src/extensions/npm/extensions",
"jest": "^26.6.3",
"mobx": "^5.15.5",
"react": "^16.13.1",
"@k8slens/extensions": "file:../../src/extensions/npm/extensions"
"ts-loader": "^8.0.4",
"typescript": "^4.0.3",
"webpack": "^4.44.2"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -16,6 +16,7 @@
"@types/react-router": "^5.1.8",
"@types/webpack": "^4.41.17",
"css-loader": "^5.0.0",
"jest": "^26.6.3",
"mobx": "^5.15.5",
"react": "^16.13.1",
"sass-loader": "^10.0.4",

File diff suppressed because it is too large Load Diff

View File

@ -17,13 +17,14 @@
"devDependencies": {
"@k8slens/extensions": "file:../../src/extensions/npm/extensions",
"@types/analytics-node": "^3.1.3",
"analytics-node": "^3.4.0-beta.3",
"jest": "^26.6.3",
"mobx": "^5.15.5",
"node-machine-id": "^1.1.12",
"react": "^16.13.1",
"ts-loader": "^8.0.4",
"typescript": "^4.0.3",
"webpack": "^4.44.2",
"mobx": "^5.15.5",
"react": "^16.13.1",
"node-machine-id": "^1.1.12",
"universal-analytics": "^0.4.23",
"analytics-node": "^3.4.0-beta.3"
"webpack": "^4.44.2"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,6 @@
"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",

View File

@ -1,94 +0,0 @@
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)