Skip to content

Commit 15d795b

Browse files
authored
fix: upgrade nctx (following node) (#315)
* fix: upgrade nctx (following node) * fix: up nctx * fix: plugins tests * fix: up modjo * fix: deploy
1 parent 58f5d55 commit 15d795b

15 files changed

Lines changed: 210 additions & 304 deletions

File tree

package.json

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"eslint-plugin-jest": "^27.0.0",
1919
"eslint-plugin-node": "^11.1.0",
2020
"eslint-plugin-prettier": "^4.0.0",
21-
"fs-extra": "^11.1.0",
21+
"fs-extra": "^11.1.1",
2222
"husky": "^8.0.0",
2323
"js-yaml": "^4.1.0",
2424
"lint-staged": "^13.0.0",
@@ -27,18 +27,6 @@
2727
"~dev-tools": "workspace:^"
2828
},
2929
"resolutions": {
30-
"@modjo/http-server": "latest",
31-
"@modjo/core": "latest",
32-
"@modjo/config": "latest",
33-
"@modjo/express": "latest",
34-
"@modjo/express-monitor": "latest",
35-
"@modjo/http-logger": "latest",
36-
"@modjo/lightship": "latest",
37-
"@modjo/logger": "latest",
38-
"@modjo/microservice-oapi": "latest",
39-
"@modjo/oa": "latest",
40-
"@modjo/shutdown-handlers": "latest",
41-
"@modjo/sentry": "latest",
4230
"tar": "^6.1.9",
4331
"multer": "^1.4.4-lts.1",
4432
"fast-copy": "^3.0.0",
@@ -76,8 +64,7 @@
7664
"docker:kontinuous:build": "DOCKER_BUILDKIT=1 docker build --progress=plain -f packages/kontinuous/Dockerfile -t kontinuous .",
7765
"docker:kontinuous:run": "docker run -it -v $PWD:/workspace -v $(dirname $KUBECONFIG):/home/node/.kube -e KUBECONFIG=/home/node/.kube/$(basename $KUBECONFIG) kontinuous",
7866
"docker:kontinuous": "yarn docker:kontinuous:build && yarn docker:kontinuous:run",
79-
"logs:remote-webhook": "kubectl --context prod -n kontinuous-webhook logs -f --all-containers -l component=kontinuous-webhook",
80-
"upgrade:modjo": "yarn up -R \"@modjo/*\""
67+
"logs:remote-webhook": "kubectl --context prod -n kontinuous-webhook logs -f --all-containers -l component=kontinuous-webhook"
8168
},
8269
"lint-staged": {
8370
"*.js": [

packages/common/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
"decompress": "^4.2.1",
1818
"direct-logger": "^2.7.3",
1919
"dotenv": "^16.0.2",
20-
"fs-extra": "^11.1.0",
20+
"fs-extra": "^11.1.1",
2121
"jest-diff": "^29.0.0",
2222
"js-yaml": "^4.1.0",
2323
"lodash.camelcase": "^4.3.0",
2424
"lodash.kebabcase": "^4.1.1",
2525
"lodash.set": "^4.3.2",
2626
"micromatch": "^4.0.5",
2727
"ms": "^2.1.3",
28-
"nctx": "^1.7.1",
28+
"nctx": "^2.2.0",
2929
"parse-url": "^8.1.0",
3030
"qs": "^6.11.0",
3131
"slugify": "^1.6.5",

packages/helm-tree/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"dependencies": {
1010
"decompress": "^4.2.1",
11-
"fs-extra": "^11.1.0",
11+
"fs-extra": "^11.1.1",
1212
"~common": "workspace:^"
1313
}
1414
}

packages/kontinuous/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"dree": "^4.0.0",
2121
"enquirer": "^2.3.6",
2222
"form-data": "^4.0.0",
23-
"fs-extra": "^11.1.0",
23+
"fs-extra": "^11.1.1",
2424
"helm-tree": "workspace:^",
2525
"launch-editor": "^2.4.0",
2626
"link-module-alias": "^1.2.0",
@@ -32,7 +32,7 @@
3232
"lodash.omit": "^4.5.0",
3333
"lodash.pick": "^4.4.0",
3434
"lodash.set": "^4.3.2",
35-
"nctx": "^1.7.1",
35+
"nctx": "^2.2.0",
3636
"nowtest": "^1.1.1",
3737
"qs": "^6.10.5",
3838
"ts-node": "^10.8.1",

packages/kontinuous/src/cli/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ const addCommands = [
2828
require("./commands/test"),
2929
]
3030

31-
module.exports = async (args = process.argv) => {
32-
ctx.provide()
33-
31+
const cli = async (args) => {
3432
const logger = ctx.get("logger") || ctx.set("logger", createLogger())
3533

3634
const signals = ["SIGTERM", "SIGHUP", "SIGINT"]
@@ -129,3 +127,9 @@ module.exports = async (args = process.argv) => {
129127
process.exit(exitCode)
130128
}
131129
}
130+
131+
module.exports = async (args = process.argv) => {
132+
await ctx.provide(async () => {
133+
await cli(args)
134+
})
135+
}

packages/kontinuous/src/deploy/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ const buildDeployPlugins = require("./build-deploy-plugins")
2121
const deploySidecars = require("./deploy-sidecars")
2222
const deployWith = require("./deploy-with")
2323

24-
module.exports = async (options) => {
25-
ctx.provide()
26-
24+
const deploy = async (options) => {
2725
await buildDeployPlugins()
2826

2927
const config = ctx.require("config")
@@ -174,3 +172,9 @@ module.exports = async (options) => {
174172
throw new ExitError(err)
175173
}
176174
}
175+
176+
module.exports = async (options) => {
177+
await ctx.provide(async () => {
178+
await deploy(options)
179+
})
180+
}

packages/kontinuous/tests/index.test.js

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -99,29 +99,30 @@ describe("test build manifests with snapshots", () => {
9999
)
100100
Object.assign(env, dotenvConfig)
101101
}
102-
ctx.provide()
103-
ctx.set("env", env)
104-
105-
const logger = createLogger({
106-
fields: {
107-
workspacePath: removePrefix(testdirPath, `${process.cwd()}/`),
108-
buildPath,
109-
},
110-
})
111-
ctx.set("logger", logger)
112-
113-
try {
114-
await cli([...process.argv.slice(0, 2), "build"])
115-
} catch (error) {
116-
if (!(error instanceof MockExit && error.exitCode === 0)) {
117-
throw error
102+
await ctx.provide(async () => {
103+
ctx.set("env", env)
104+
105+
const logger = createLogger({
106+
fields: {
107+
workspacePath: removePrefix(testdirPath, `${process.cwd()}/`),
108+
buildPath,
109+
},
110+
})
111+
ctx.set("logger", logger)
112+
113+
try {
114+
await cli([...process.argv.slice(0, 2), "build"])
115+
} catch (error) {
116+
if (!(error instanceof MockExit && error.exitCode === 0)) {
117+
throw error
118+
}
118119
}
119-
}
120120

121-
const result = ctx.require("result")
122-
const { manifests } = result
123-
expect(manifests).toMatchSpecificSnapshot(
124-
`./__snapshots__/${testdir}.${environment}.yaml`
125-
)
121+
const result = ctx.require("result")
122+
const { manifests } = result
123+
expect(manifests).toMatchSpecificSnapshot(
124+
`./__snapshots__/${testdir}.${environment}.yaml`
125+
)
126+
})
126127
})
127128
})

packages/webhook/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
"test": "jest tests"
1313
},
1414
"dependencies": {
15-
"@modjo/core": "latest",
16-
"@modjo/express": "^1.0.14",
17-
"@modjo/microservice-oapi": "^1.0.5",
18-
"@modjo/sentry": "^1.2.0",
15+
"@modjo/core": "^1.2.6",
16+
"@modjo/express": "^1.2.6",
17+
"@modjo/microservice-oapi": "^1.2.6",
18+
"@modjo/sentry": "^1.2.6",
1919
"@vercel/ncc": "^0.36.0",
2020
"async-retry": "^1.3.3",
2121
"chokidar": "^3.5.3",
22-
"fs-extra": "^11.1.0",
22+
"fs-extra": "^11.1.1",
2323
"helm-tree": "workspace:^",
2424
"link-module-alias": "^1.2.0",
2525
"lodash.defaultsdeep": "^4.6.1",
2626
"lodash.mergewith": "^4.6.2",
27-
"nctx": "^1.7.1",
27+
"nctx": "^2.2.0",
2828
"node-cron": "^3.0.0",
2929
"rimraf": "^4.1.2",
3030
"uuid": "^9.0.0",

packages/webhook/src/daemon.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ module.exports = async () => {
99
return
1010
}
1111

12-
ctx.provide()
13-
14-
// at minute 0 past every 6th hour. see https://crontab.guru/
15-
cron.schedule("0 */6 * * *", cleanArtifact)
12+
await ctx.provide(async () => {
13+
// at minute 0 past every 6th hour. see https://crontab.guru/
14+
cron.schedule("0 */6 * * *", cleanArtifact)
15+
})
1616
}

packages/webhook/src/server.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ module.exports = async (options = {}) => {
4141
},
4242
},
4343
})
44-
commonCtx.provide()
45-
await modjo(options)
44+
await commonCtx.provide(async () => {
45+
await modjo(options)
46+
})
4647
}

0 commit comments

Comments
 (0)