Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(rwfw): working refactor, make project:sync ignore more files #8579

Merged
merged 12 commits into from
Jun 13, 2023
34 changes: 21 additions & 13 deletions tasks/framework-tools/frameworkDepsToProject.mjs
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
#!/usr/bin/env node
/* eslint-env node */
// @ts-check

import path from 'node:path'

import { addDependenciesToPackageJson } from './lib/project.mjs'

const projectPath = process.argv?.[2] ?? process.env.RWJS_CWD
function main() {
const projectPath = process.argv?.[2] ?? process.env.RWJS_CWD

if (!projectPath) {
console.log('Error: Please specify the path to your Redwood Project')
console.log(`Usage: ${process.argv?.[1]} /path/to/rwjs/proect`)
process.exit(1)
}
if (!projectPath) {
process.exitCode = 1
console.error([
'Error: Please specify the path to your Redwood project',
`Usage: ${process.argv?.[1]} ./path/to/rw/project`,
])
return
}

try {
const packageJsonPath = path.join(projectPath, 'package.json')
addDependenciesToPackageJson(packageJsonPath)
console.log('Done. Now run `yarn install`.')
} catch (e) {
console.log('Error:', e.message)
process.exit(1)
try {
const packageJsonPath = path.join(projectPath, 'package.json')
addDependenciesToPackageJson(packageJsonPath)
console.log('Done. Now run `yarn install`.')
} catch (e) {
console.log('Error:', e.message)
process.exitCode = 1
}
}

main()
31 changes: 20 additions & 11 deletions tasks/framework-tools/frameworkFilesToProject.mjs
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
#!/usr/bin/env node
/* eslint-env node */
// @ts-check

import { copyFrameworkFilesToProject } from './lib/project.mjs'

const projectPath = process.argv?.[2] ?? process.env.RWJS_CWD
async function main() {
const redwoodProjectPath = process.argv?.[2] ?? process.env.RWJS_CWD

if (!projectPath) {
console.log('Error: Please specify the path to your Redwood Project')
console.log(`Usage: ${process.argv?.[1]} /path/to/rwjs/proect`)
process.exit(1)
}
// Mostly just making TS happy with the second condition.
if (!redwoodProjectPath || typeof redwoodProjectPath !== 'string') {
process.exitCode = 1
console.error([
'Error: Please specify the path to your Redwood project',
`Usage: ${process.argv?.[1]} ./path/to/rw/project`,
])
return
}

try {
await copyFrameworkFilesToProject(projectPath)
} catch (e) {
console.error('Error:', e.message)
process.exit(1)
try {
await copyFrameworkFilesToProject(redwoodProjectPath)
} catch (e) {
console.error('Error:', e.message)
process.exitCode = 1
}
}

main()
Loading