Skip to content

Commit

Permalink
Move framework-tools deps to root package.json (#3908)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Choudhury <dannychoudhury@gmail.com>
  • Loading branch information
jtoar and dac09 authored Dec 16, 2021
1 parent bc8b569 commit 6f6f7ca
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 675 deletions.
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,23 @@
"@types/jscodeshift": "0.11.2",
"@types/lodash.template": "4",
"all-contributors-cli": "6.20.0",
"ansi-colors": "4.1.1",
"babel-jest": "27.3.1",
"babel-plugin-auto-import": "1.1.0",
"babel-plugin-remove-code": "0.0.6",
"core-js": "3.20.0",
"eslint": "8.4.1",
"fast-glob": "3.2.7",
"jest": "27.3.1",
"jscodeshift": "0.13.0",
"lerna": "4.0.0",
"lodash.template": "4.5.0",
"nodemon": "2.0.15",
"npm-packlist": "3.0.0",
"octokit": "1.7.1",
"ora": "5.4.1",
"rimraf": "3.0.2",
"terminal-link": "2.1.1",
"typescript": "4.5.2",
"typescript-transform-paths": "3.3.1"
},
Expand All @@ -51,7 +55,6 @@
"vscode-languageserver-textdocument": "1.0.3"
},
"scripts": {
"framework": "yarn ./tasks/framework-tools",
"build": "yarn build:js && yarn build:types",
"build:js": "lerna run build:js",
"build:types": "tsc --build --verbose",
Expand All @@ -62,11 +65,13 @@
"clean:prisma": "rimraf node_modules/.prisma/client && node node_modules/@prisma/client/scripts/postinstall.js",
"lint": "RWJS_CWD=packages/create-redwood-app/template eslint --config .eslintrc.js packages",
"lint:fix": "yarn lint --fix",
"postinstall": "yarn framework install",
"build:link": "node ./tasks/build-and-copy",
"build:test-project": "node ./tasks/test-project/test-project",
"release-notes": "node ./tasks/release-notes/release-notes.mjs",
"publish:canary": "lerna publish --force-publish --canary --include-merged-tags --preid canary --dist-tag canary --yes --loglevel verbose"
"publish:canary": "lerna publish --force-publish --canary --include-merged-tags --preid canary --dist-tag canary --yes --loglevel verbose",
"project:deps": "node ./tasks/framework-tools/frameworkDepsToProject.mjs",
"project:copy": "node ./tasks/framework-tools/frameworkFilesToProject.mjs",
"project:sync": "node ./tasks/framework-tools/frameworkSyncToProject.mjs"
},
"packageManager": "yarn@3.0.2"
}
5 changes: 2 additions & 3 deletions packages/cli/src/rwfw.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ config.set('RWFW_PATH', absRwFwPath)
const projectPath = path.dirname(
getConfigPath(process.env.RWJS_CWD ?? process.cwd())
)
const fwToolsPath = path.join(absRwFwPath, 'tasks/framework-tools')
console.log(
'Redwood Framework Tools Path:',
TerminalLink(fwToolsPath, fwToolsPath)
TerminalLink(absRwFwPath, absRwFwPath)
)

let command = process.argv.slice(2)
Expand All @@ -48,7 +47,7 @@ if (!command.length || command.some((cmd) => helpCommands.includes(cmd))) {
}

try {
execa.sync('yarn', ['--cwd', fwToolsPath, ...command], {
execa.sync('yarn', ['--cwd', absRwFwPath, ...command], {
stdio: 'inherit',
shell: true,
env: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env node
/* eslint-env node */

import path from 'path'
import path from 'node:path'

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

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`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { copyFrameworkFilesToProject } from './lib/project.mjs'

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`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/env node
/* eslint-env node */

import fs from 'fs'
import path from 'path'

import c from 'ansi-colors'
import chokidar from 'chokidar'
import fs from 'node:fs'
import path from 'node:path'

import {
REDWOOD_PACKAGES_PATH,
Expand All @@ -21,6 +20,7 @@ import {
} from './lib/project.mjs'

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/project`)
Expand All @@ -29,6 +29,7 @@ if (!projectPath) {

// Cache the original package.json and restore it when this process exits.
const projectPackageJsonPath = path.join(projectPath, 'package.json')

const projectPackageJson = fs.readFileSync(projectPackageJsonPath, 'utf-8')
process.on('SIGINT', () => {
console.log()
Expand Down Expand Up @@ -62,7 +63,7 @@ chokidar
['.DS_Store'].some((ext) => file.endsWith(ext)),
})
.on('ready', async () => {
logStatus('Building Framework...')
logStatus('Cleaning Framework...')
cleanPackages()

logStatus('Building Framework...')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
/* eslint-env node */

import fs from 'fs'
import path from 'path'
import { dirname } from 'path'
import { fileURLToPath } from 'url'

import c from 'ansi-colors'
import execa from 'execa'
import fg from 'fast-glob'
import fs from 'node:fs'
import path from 'node:path'
import url from 'node:url'
import packlist from 'npm-packlist'

const __dirname = dirname(fileURLToPath(import.meta.url))
const __dirname = path.dirname(url.fileURLToPath(import.meta.url))

export const REDWOOD_PACKAGES_PATH = path.resolve(
__dirname,
'../../../../packages'
'../../../packages'
)

/**
Expand All @@ -34,7 +33,7 @@ export function frameworkPkgJsonFiles() {
}

/**
* The dependencenies used by `@redwoodjs` packages.
* The dependencies used by `@redwoodjs` packages.
*/
export function frameworkDependencies(packages = frameworkPkgJsonFiles()) {
const dependencies = {}
Expand Down Expand Up @@ -152,7 +151,7 @@ export function cleanPackages(packages = frameworkPkgJsonFiles()) {
{
shell: true,
stdio: 'inherit',
cwd: path.resolve(__dirname, '../../../../'),
cwd: path.resolve(__dirname, '../../../'),
}
)
}
Expand All @@ -170,15 +169,15 @@ export function buildPackages(packages = frameworkPkgJsonFiles()) {
{
shell: true,
stdio: 'inherit',
cwd: path.resolve(__dirname, '../../../../'),
cwd: path.resolve(__dirname, '../../../'),
}
)

// Build all TypeScript.
execa.sync('yarn build:types', undefined, {
shell: true,
stdio: 'inherit',
cwd: path.resolve(__dirname, '../../../../'),
cwd: path.resolve(__dirname, '../../../'),
})
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* eslint-env node */

import fs from 'fs'
import path from 'path'

import execa from 'execa'
import fs from 'node:fs'
import path from 'node:path'
import ora from 'ora'
import rimraf from 'rimraf'
import terminalLink from 'terminal-link'
Expand Down Expand Up @@ -41,7 +40,7 @@ export function fixProjectBinaries(projectPath) {
*/
export function addDependenciesToPackageJson(
packageJsonPath,
dependencenies = frameworkDependencies()
dependencies = frameworkDependencies()
) {
if (!fs.existsSync(packageJsonPath)) {
console.log(
Expand All @@ -55,7 +54,7 @@ export function addDependenciesToPackageJson(
'file://' + packageJsonPath
)

const numOfDeps = Object.keys(dependencenies).length
const numOfDeps = Object.keys(dependencies).length

const spinner = ora(
`Adding ${numOfDeps} framework dependencies to ${packageJsonLink}...`
Expand All @@ -64,7 +63,7 @@ export function addDependenciesToPackageJson(
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))
packageJson.dependencies = {
...(packageJson.dependencies || {}),
...dependencenies,
...dependencies,
}
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, undefined, 2))
spinner.succeed(
Expand Down
20 changes: 0 additions & 20 deletions tasks/framework-tools/package.json

This file was deleted.

Loading

0 comments on commit 6f6f7ca

Please sign in to comment.