Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

WIP: (refactor): Templates management and workflows #6

Closed
wants to merge 26 commits into from

Conversation

JayaKrishnaNamburu
Copy link

@JayaKrishnaNamburu JayaKrishnaNamburu commented Jul 29, 2023

closes #5

Now, the cli has three commands, sync, link, build. Here is the workflow that this aims to solve.

Creating a new project

  • Users deploy a project in the studio (I am not sure, if this limitation can be removed).
  • Then webstudio link <url> links the project and adds to the global configuration.
  • webstudio build <projectId> clone the project locally by creating a folder webstudio-projectand then saves the project data aswebstudio.json` inside the project.
  • Once the build it is, it is ready to be hosted.

Managing the existing project

  • Since the project is already linked, the link steps is not needed anymore.
  • Then we can run webstudio sync inside the project. If the users want to decide to just sync the data.
  • webstudio buil builds the project once again. The above step webstudio sync is not mandatory. Since during the webstudio build command the cli sync's the project anyways with the latest data.

TODO:

  • Download all the assets, so they can be hosted on their own. Right now, assets don't work at all.
  • Decide if the cli needs hosting integrated in the first iteration.
  • the function executeComputingExpressions is needed for Instace component. But currently we are not sending it now. Need to see why it is needed.

@JayaKrishnaNamburu JayaKrishnaNamburu changed the title (refactor): Templates management and workflows WIP: (refactor): Templates management and workflows Jul 29, 2023
package.json Outdated
@@ -6,33 +6,34 @@
"repository": "[email protected]:webstudio-is/webstudio-cli.git",
"homepage": "https://webstudio.is",
"scripts": {
"dev": "pnpm build --watch",
"prebuild": "tsx ./lib/prebuild.js",
Copy link
Author

Choose a reason for hiding this comment

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

the prebuild script is needed for building the project. But this way, this is going to go as a project script instead of running inside users project. So, this need to be run as a build step inside users project folder.

package.json Outdated
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"build": "pnpm format && pnpm clean && esbuild ./src/* --outdir=./lib --platform=node",
"clean": "rm -fr ./lib"
},
"type": "module",
"bin": {
"webstudio": "./bin/cli.sh"
Copy link
Author

Choose a reason for hiding this comment

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

bin/cli.js is enough, the cli don't need to have .sh script

@@ -1,4 +1,4 @@
#!/usr/bin/env node
#!/usr/bin/env node --experimental-specifier-resolution=node
Copy link
Author

Choose a reason for hiding this comment

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

The cli is written in ecam modules. And they are being disctributed without any build step. But after node@18 node needs .js extension to resolve any file. Because they introduced support for .mjs extension. This works fine when the project is not using any deps. But in this case we have many dependencies for the cli which don't use .js. This flag let's the node that it can resolve them without using .js extension.

@JayaKrishnaNamburu JayaKrishnaNamburu self-assigned this Jul 29, 2023
@JayaKrishnaNamburu JayaKrishnaNamburu linked an issue Jul 29, 2023 that may be closed by this pull request
@TrySound TrySound changed the base branch from new-cli to main July 30, 2023 10:25
@@ -0,0 +1,84 @@
/*
Copy link
Member

Choose a reason for hiding this comment

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

please use __generated__ folder like we do in the builder repo

@@ -1,51 +1,39 @@
import { loadProject } from "@webstudio-is/http-client";
Copy link
Member

Choose a reason for hiding this comment

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

why is it being removed? the idea is that http-client is ALWAYS used to access the API from both: saas deployment and CLI ...

Copy link
Author

Choose a reason for hiding this comment

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

No clue, got this from my upstream branch

@istarkov
Copy link
Member

istarkov commented Jul 30, 2023

Having this repo out of main repo would cause same issues we permanently have in SaaS repo.
As no change in the main monorepo somehow affects developer to do fixes here.

So the plan is to move the cli into the main monorepo under the apps/cli directory.
And let's do move using smallest possible PRs.

I see move steps like.

  1. Move only parsing and command execution logic. Like it's done in wrangler or similar tools.
    Source of inspiration
    No need to use yargs etc, naive node parser is ok. The idea is to universally add any command to the cli.
    Should be small simple PR.

  2. Add command by command. Single/Multiple small PR/PRs for each.
    2.1. link, config
    2.2 sync json
    2.3 sync artifacts
    2.4 Create build for ${PLATFORM:-vercel}
    2.4 add remix build of some existing project to github action/vercel so at every PR we will know that publishing is working (for simplicity we do not add publish button support to monorepo, we just publish any single existing project during PR build/checks/deploy)
    2.5 PLATFORM=nextPlatform(); GOTO 2.4

cc @TrySound @kof

@TrySound
Copy link
Member

TrySound commented Jul 30, 2023

please use node native import { parseArgs } from 'node:util' for parsing arguments
we want our cli to be small in example for others

@JayaKrishnaNamburu
Copy link
Author

@TrySound and @istarkov right now the cli is using the same from node:util should we keep it the same or move to yargs or something ??
https://github.com/webstudio-is/webstudio-cli/blob/refactor/new-cli/src/index.ts#L22

@TrySound
Copy link
Member

TrySound commented Aug 1, 2023

ah, good. keep it

@kof
Copy link
Member

kof commented Aug 6, 2023

Just to inform: we decided this PR can't be merged and we will rewrite this PR in small chunks as part of the builder monorepo package. One PR at a time

Follow progress here https://github.com/webstudio-is/webstudio-builder/pulls?q=is%3Apr+label%3Aarea%3Acli+

@kof kof closed this Aug 6, 2023
JayaKrishnaNamburu added a commit to webstudio-is/webstudio that referenced this pull request Aug 28, 2023
## Description

This PR moves the cli from `apps/cli` into `packages` folder. It was
initially started under `app/cli` from this
[comment](webstudio-is/webstudio-cli#6 (comment)).
But looks like, `packages` is the good place for it.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Workflow and use-cases
5 participants