Skip to content

Commit

Permalink
working refactor, make project:sync ignore more
Browse files Browse the repository at this point in the history
  • Loading branch information
jtoar committed Jun 10, 2023
1 parent 708902d commit 84ce669
Show file tree
Hide file tree
Showing 5 changed files with 415 additions and 233 deletions.
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

0 comments on commit 84ce669

Please sign in to comment.