Skip to content

Commit

Permalink
Merge branch 'main' into ari/remove-mjs-docgen
Browse files Browse the repository at this point in the history
  • Loading branch information
arimendelow authored Aug 22, 2024
2 parents d527cda + a9c39c8 commit f5ef4ca
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 74 deletions.
4 changes: 3 additions & 1 deletion packages/cli-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
"prompts": "2.4.2",
"semver": "7.6.3",
"smol-toml": "1.3.0",
"terminal-link": "2.1.1"
"terminal-link": "2.1.1",
"yargs-parser": "21.1.1"
},
"devDependencies": {
"@redwoodjs/framework-tools": "workspace:*",
Expand All @@ -78,6 +79,7 @@
"@types/pascalcase": "1.0.3",
"@types/semver": "^7",
"@types/yargs": "17.0.33",
"@types/yargs-parser": "21.0.3",
"tsx": "4.17.0",
"typescript": "5.5.4",
"vitest": "2.0.5"
Expand Down
1 change: 1 addition & 0 deletions packages/cli-helpers/src/lib/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import chalk from 'chalk'
export const colors = {
error: chalk.bold.red,
warning: chalk.hex('#ffa500'),
highlight: chalk.hex('#ffa500'),
success: chalk.green,
info: chalk.grey,
bold: chalk.bold,
Expand Down
5 changes: 3 additions & 2 deletions packages/cli-helpers/src/lib/loadEnvFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import path from 'node:path'

import { config as dotenvConfig } from 'dotenv'
import { config as dotenvDefaultsConfig } from 'dotenv-defaults'
import { hideBin, Parser } from 'yargs/helpers'
import { hideBin } from 'yargs/helpers'
import parser from 'yargs-parser'

import { getPaths } from '@redwoodjs/project-config'

Expand All @@ -17,7 +18,7 @@ export function loadEnvFiles() {
loadDefaultEnvFiles(base)
loadNodeEnvDerivedEnvFile(base)

const { loadEnvFiles } = Parser.default(hideBin(process.argv), {
const { loadEnvFiles } = parser(hideBin(process.argv), {
array: ['load-env-files'],
default: {
loadEnvFiles: [],
Expand Down
1 change: 1 addition & 0 deletions packages/cli-packages/dataMigrate/src/lib/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import chalk from 'chalk'
export default {
error: chalk.bold.red,
warning: chalk.hex('#ffa500'),
highlight: chalk.hex('#ffa500'),
success: chalk.green,
info: chalk.grey,
bold: chalk.bold,
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/commands/setup/jobs/jobsHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ const tasks = async ({ force }) => {
${c.success('\nBackground jobs configured!\n')}
${!modelExists ? 'Migrate your database to finish setting up jobs:\n' : ''}
${!modelExists ? c.warning('\n\u00A0\u00A0yarn rw prisma migrate dev\n') : ''}
${!modelExists ? c.highlight('\n\u00A0\u00A0yarn rw prisma migrate dev\n') : ''}
Generate jobs with: ${c.warning('yarn rw g job <name>')}
Execute jobs with: ${c.warning('yarn rw jobs work\n')}
Generate jobs with: ${c.highlight('yarn rw g job <name>')}
Execute jobs with: ${c.highlight('yarn rw jobs work\n')}
Check out the docs for more info:
${c.link('https://docs.redwoodjs.com/docs/background-jobs')}
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/lib/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import chalk from 'chalk'
export default {
error: chalk.bold.red,
warning: chalk.hex('#ffa500'),
highlight: chalk.hex('#ffa500'),
success: chalk.green,
info: chalk.grey,
bold: chalk.bold,
Expand Down
2 changes: 2 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"rw-dev-fe": "./dist/bins/rw-dev-fe.js",
"rw-gen": "./dist/bins/rw-gen.js",
"rw-gen-watch": "./dist/bins/rw-gen-watch.js",
"rw-jobs": "./dist/bins/rw-jobs.js",
"rw-jobs-worker": "./dist/bins/rw-jobs-worker.js",
"rw-log-formatter": "./dist/bins/rw-log-formatter.js",
"rw-serve-api": "./dist/bins/rw-serve-api.js",
"rw-serve-fe": "./dist/bins/rw-serve-fe.js",
Expand Down
11 changes: 11 additions & 0 deletions packages/core/src/bins/rw-jobs-worker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env node
import { createRequire } from 'node:module'

const require = createRequire(import.meta.url)
const requireFromRwJobs = createRequire(
require.resolve('@redwoodjs/jobs/package.json'),
)

const bins = requireFromRwJobs('./package.json')['bin']

requireFromRwJobs(bins['rw-jobs-worker'])
11 changes: 11 additions & 0 deletions packages/core/src/bins/rw-jobs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env node
import { createRequire } from 'node:module'

const require = createRequire(import.meta.url)
const requireFromRwJobs = createRequire(
require.resolve('@redwoodjs/jobs/package.json'),
)

const bins = requireFromRwJobs('./package.json')['bin']

requireFromRwJobs(bins['rw-jobs'])
3 changes: 3 additions & 0 deletions packages/jobs/build.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { build } from '@redwoodjs/framework-tools'

await build()
32 changes: 0 additions & 32 deletions packages/jobs/build.ts

This file was deleted.

17 changes: 6 additions & 11 deletions packages/jobs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,17 @@
"directory": "packages/jobs"
},
"license": "MIT",
"type": "module",
"type": "commonjs",
"exports": {
".": {
"import": {
"default": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"default": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.js"
}
}
},
"./package.json": "./package.json"
},
"main": "./dist/cjs/index.js",
"module": "./dist/index.js",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"bin": {
"rw-jobs": "./dist/bins/rw-jobs.js",
Expand All @@ -31,10 +27,9 @@
"dist"
],
"scripts": {
"build": "tsx ./build.ts",
"build": "tsx ./build.mts && yarn build:types",
"build:pack": "yarn pack -o redwoodjs-jobs.tgz",
"build:types": "tsc --build --verbose ./tsconfig.build.json",
"build:types-cjs": "tsc --build --verbose ./tsconfig.cjs.json",
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx\" --ignore dist --exec \"yarn build\"",
"check:attw": "yarn rw-fwtools-attw",
"check:package": "concurrently npm:check:attw yarn:publint",
Expand Down
16 changes: 6 additions & 10 deletions packages/jobs/src/bins/rw-jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,11 @@ export const startWorkers = ({
}

// fork the worker process
const worker = fork(
path.join(import.meta.dirname, 'rw-jobs-worker.js'),
workerArgs,
{
detached: detach,
stdio: detach ? 'ignore' : 'inherit',
env: process.env,
},
)
const worker = fork(path.join(__dirname, 'rw-jobs-worker.js'), workerArgs, {
detached: detach,
stdio: detach ? 'ignore' : 'inherit',
env: process.env,
})

if (detach) {
worker.unref()
Expand Down Expand Up @@ -181,7 +177,7 @@ const stopWorkers = async ({

const clearQueue = ({ logger }: { logger: BasicLogger }) => {
logger.warn(`Starting worker to clear job queue...`)
fork(path.join(import.meta.dirname, 'rw-jobs-worker.js'), ['--clear'])
fork(path.join(__dirname, 'rw-jobs-worker.js'), ['--clear'])
}

const signalSetup = ({
Expand Down
15 changes: 0 additions & 15 deletions packages/jobs/tsconfig.cjs.json

This file was deleted.

4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7898,6 +7898,7 @@ __metadata:
"@types/pascalcase": "npm:1.0.3"
"@types/semver": "npm:^7"
"@types/yargs": "npm:17.0.33"
"@types/yargs-parser": "npm:21.0.3"
chalk: "npm:4.1.2"
dotenv: "npm:16.4.5"
dotenv-defaults: "npm:5.0.2"
Expand All @@ -7913,6 +7914,7 @@ __metadata:
tsx: "npm:4.17.0"
typescript: "npm:5.5.4"
vitest: "npm:2.0.5"
yargs-parser: "npm:21.1.1"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -8112,6 +8114,8 @@ __metadata:
rw-dev-fe: ./dist/bins/rw-dev-fe.js
rw-gen: ./dist/bins/rw-gen.js
rw-gen-watch: ./dist/bins/rw-gen-watch.js
rw-jobs: ./dist/bins/rw-jobs.js
rw-jobs-worker: ./dist/bins/rw-jobs-worker.js
rw-log-formatter: ./dist/bins/rw-log-formatter.js
rw-serve-api: ./dist/bins/rw-serve-api.js
rw-serve-fe: ./dist/bins/rw-serve-fe.js
Expand Down

0 comments on commit f5ef4ca

Please sign in to comment.