Skip to content

Add the setup command#1154

Merged
peterp merged 9 commits intoredwoodjs:mainfrom
noire-munich:pr/setup
Sep 23, 2020
Merged

Add the setup command#1154
peterp merged 9 commits intoredwoodjs:mainfrom
noire-munich:pr/setup

Conversation

@noire-munich
Copy link
Copy Markdown
Contributor

Looping back on thread https://community.redwoodjs.com/t/rw-setup-proposal-complementing-generators-with-setup/1123/5

This adds a new setup command, which will offer developers setup scripts for their projects.

The current PR proposes:

  • i18n support
  • tailwindcss support ( migrated from generate util )

Auth and Deploy commands should migrate there as well.

@noire-munich
Copy link
Copy Markdown
Contributor Author

@thedavidprice So! moving here :)

About testing I'm using the following command:
yarn rwt copy:watch /Workspace/Code/RedwoodjsForks/upstream

which persistently pops me a :

 /Workspace/Code/RedwoodjsForks/web/node_modules/.bin/rw g
internal/modules/cjs/loader.js:965
  throw err;
  ^

Error: Cannot find module 'lodash-decorators'
Require stack:
- /Workspace/Code/RedwoodjsForks/web/node_modules/@redwoodjs/structure/dist/x/decorators.js
- /Workspace/Code/RedwoodjsForks/web/node_modules/@redwoodjs/structure/dist/hosts.js
- /Workspace/Code/RedwoodjsForks/web/node_modules/@redwoodjs/structure/dist/index.js
- /Workspace/Code/RedwoodjsForks/web/node_modules/@redwoodjs/cli/dist/commands/check.js
- /Workspace/Code/RedwoodjsForks/web/node_modules/yargs/index.js
- /Workspace/Code/RedwoodjsForks/web/node_modules/@redwoodjs/cli/dist/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:962:15)
    at Function.Module._load (internal/modules/cjs/loader.js:838:27)
    at Module.require (internal/modules/cjs/loader.js:1022:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/Workspace/Code/RedwoodjsForks/web/node_modules/@redwoodjs/structure/dist/x/decorators.js:32:25)
    at Module._compile (internal/modules/cjs/loader.js:1118:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
    at Module.load (internal/modules/cjs/loader.js:982:32)
    at Function.Module._load (internal/modules/cjs/loader.js:875:14)
    at Module.require (internal/modules/cjs/loader.js:1022:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Workspace/Code/RedwoodjsForks/web/node_modules/@redwoodjs/structure/dist/x/decorators.js',
    '/Workspace/Code/RedwoodjsForks/web/node_modules/@redwoodjs/structure/dist/hosts.js',
    '/Workspace/Code/RedwoodjsForks/web/node_modules/@redwoodjs/structure/dist/index.js',
    '/Workspace/Code/RedwoodjsForks/web/node_modules/@redwoodjs/cli/dist/commands/check.js',
    '/Workspace/Code/RedwoodjsForks/web/node_modules/yargs/index.js',
    '/Workspace/Code/RedwoodjsForks/web/node_modules/@redwoodjs/cli/dist/index.js'
  ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Whichever command I call.

I tried the straightforward build & copy which yields more results but equal satisfaction: my new commands are detected and supposedly launched but as soon as they refer to template files it crashed. I then realize that the related directories went from present & working to missing in action.

Bummer.
For the record this is not new to v0.18.0, it has always been this way for my contributions :-\

@thedavidprice
Copy link
Copy Markdown
Contributor

Yesssss 🚀

Looping in @jtoar (YargsMaster™) and @peterp (TheMaster™)

Will be digging into this very soon.

Comment thread packages/cli/src/commands/setup.js Outdated
Comment thread packages/cli/src/commands/setup.js Outdated
Comment thread packages/cli/src/commands/setup.js Outdated
Comment thread packages/cli/src/commands/setup/i18n/i18n.js Outdated
* Write i18n.js in web/src
*/
return writeFile(
getPaths().web.src,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This path seems incorrect? Should it not be something like path.join(paths.web.src, i18n.js)

@peterp peterp changed the title Pr/setup Add the setup command Sep 17, 2020
@noire-munich noire-munich requested a review from peterp September 18, 2020 08:24
Copy link
Copy Markdown
Member

@peterp peterp left a comment

Choose a reason for hiding this comment

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

This looks good to me - we're going to merge a fix for autoprefixer/ tailwind soon that will introduce a merge config, but this can go in v0.20.0

@peterp
Copy link
Copy Markdown
Member

peterp commented Sep 23, 2020

@noire-munich Thanks for this - In the future I would would love to figure out a way to make it easy to run setup commands over http (which was mentioned in the original spec), maybe you can give that some thoughts?

yarn redwood setup http://github.com/peterp/docker-tool/docker-tool.json

This docker-tool.json file would need to describe the following operations:

  1. Add packages.
  2. Modify files. (replace/ delete/ add)
  3. Run other redwood commands.

@peterp peterp merged commit ffbcef9 into redwoodjs:main Sep 23, 2020
@peterp peterp added this to the Next release milestone Sep 23, 2020
@noire-munich
Copy link
Copy Markdown
Contributor Author

@peterp no problem :) I played with the idea actually...
I was wondering if it would make sense to limit the commands available, as all commands from redwood would not be relevant?
And maybe provide some typescript to guide developers through editing remote setup instructions, typescript which could include the set of available commands. Is it something we'd want to do, or save for a later version?

@thedavidprice
Copy link
Copy Markdown
Contributor

@noire-munich regarding "running setup commands over https" -- looping in @jtoar and @dac09 who have both done some initial POC exploration on this concept. Perhaps one of you could open a new Issue to loop everyone in and swap some notes + create a plan of attack. I don't think this is a high priority feature, however, we're concerned it might require Yargs to be constructed in a specific manner, which we'd like to know sooner than later.

limit the commands available

^^ Hmm, I'm not sure if this would be necessary. At the least, likely something to figure out as we go.

And maybe provide some typescript to guide developers through editing remote setup instructions, typescript which could include the set of available commands. Is it something we'd want to do or save for a later version?

^^ +1 to TS if it makes sense in the implementation.

@noire-munich
Copy link
Copy Markdown
Contributor Author

noire-munich commented Oct 10, 2020

Hi @thedavidprice !
Sorry, I'm a bit off the radar lately :)
I created #1323 per your suggestion and the idea of splitting the command to accept options is indeed something we should figure out early on.

Noted for the two other points :), let's see how it goes with the #1323 team!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants