kitconcept / volto-form-builder

An interactive form builder for Volto, that allows editors to assemble forms via drag and drop.
4 stars 5 forks source link

Refactor volto-form-builder to user yarn workspaces #38

Open tisto opened 4 years ago

tisto commented 4 years ago
  1. Move current project root to /src/addons/volto-form-builder
  2. Add a top-level configuration that includes volto-form-builder
tiberiuichim commented 4 years ago
  1. Generate a new project with create-volto-app
  2. Add a mrs.developer file with the following content:
{
  "volto-formbuilder": {
    "package": "@kitconcept/volto-formbuilder",
    "url": "https://github.com/kitconcept/volto-formbuilder.git",
    "path": "src"
  }
}
  1. Adjust package.json to change:
  "scripts": {
    "develop:npx": "npx -p mrs-developer missdev --config=jsconfig.json --output=addons",
    "develop": "missdev --config=jsconfig.json --output=addons",
    "preinstall": "if [ -f $(pwd)/node_modules/.bin/missdev ]; then yarn develop; else yarn develop:npx; fi",
    "start": "razzle start",
    "postinstall": "yarn omelette && yarn patches",
    "omelette": "ln -sf node_modules/@plone/volto/ omelette",
    "patches": "/bin/bash patches/patchit.sh > /dev/null 2>&1 ||true",
    "build": "razzle build",
    "test": "razzle test --env=jsdom --passWithNoTests",
    "start:prod": "NODE_ENV=production node build/server.js",
    "i18n": "NODE_ENV=production node node_modules/@plone/volto/src/i18n.js"
  },

This makes sure it runs missdev before "yarn install"

  "addons": [
    "@kitconcept/volto-formbuilder"
  ],
  "workspaces": [
    "src/addons/volto-formbuilder"
  ],
    "moduleNameMapper": {
      "@plone/volto/babel": "<rootDir>/node_modules/@plone/volto/babel",
      "@plone/volto/(.*)$": "<rootDir>/node_modules/@plone/volto/src/$1",
      "load-volto-addons": "<rootDir>/node_modules/@plone/volto/dummy-addons-loader.js",
      "@package/(.*)$": "<rootDir>/src/$1",
      "volto-formbuilder/(.*)$": "<rootDir>/src/addons/volto-formbuilder/src/$1"
      "~/(.*)$": "<rootDir>/src/$1"
    },

Now run yarn install, yarn start.

I think it would be a good idea to migrate the jest configuration to jest.config.js, then we could use addons-registry to get the addons mappings.

tisto commented 4 years ago
  1. create-volto-app

package.json:

  "private": "true",
  "addons": [
    "@kitconcept/volto-form-builder"
  ],
  "workspaces": [
    "src/addons/volto-form-builder"
  ],
    "moduleNameMapper": {
      ...
      "@kitconcept/volto-form-builder/(.*)$": "<rootDir>/src/addons/volto-form-builder/src/$1",
tisto commented 4 years ago

@tiberiuichim ok, this is the same what I did so far in other projects. Why do we need mrs.developer when we put the source code into /src/addons/volto-form-builder?

tiberiuichim commented 4 years ago

Old habit, sorry. missdev is useful as it updates jsconfig.json, but you're right, it's not needed.