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

Move framework-tools deps to root package.json #3908

Merged
merged 10 commits into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": "[email protected]"
}
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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you doing this here? I'm confused... why is this necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the node protocol. It's just a new feature in ES Modules: https://nodejs.org/api/esm.html#node-imports. There's no meaningful difference; the only justification I have is

  1. using URLs is more web-y than the previous way of doing things
  2. it's easier for beginners (they can tell that this is from the node std lib)

The Node.js docs will most likely use it in the future too: nodejs/node#38343.

Can remove it though; just added it cause I liked it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it. Keep us moving in that direction, k? My only concern would be using features that aren't supported in v16 (i.e. > 16 only).


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, '../../../'),
dac09 marked this conversation as resolved.
Show resolved Hide resolved
}
)
}
Expand All @@ -170,15 +169,15 @@ export function buildPackages(packages = frameworkPkgJsonFiles()) {
{
shell: true,
stdio: 'inherit',
cwd: path.resolve(__dirname, '../../../../'),
cwd: path.resolve(__dirname, '../../../'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, not sure why this path has changed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did move it actually; the filepath used to be tasks/framework-tools/src/lib/framework.mjs.

}
)

// 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