Skip to content

support dynamically changing properties in template code #40

@juancarlosfarah

Description

@juancarlosfarah

Motivation

If the template has a public/index.html, then try to make the following changes:

Update the title of the app to the name of the app. Example:

<title>My App</title> .

If the template has a a public/manifest.json, modify the short_name and name fields:

"short_name": "My App",
"name": "My App",

Proposal

The locations where these things need to be changed could be made dynamic using a .graasprc file in the template repository. Similar to the way that we delete files listed in a .graaspignore file.

Steps:

  1. Read a .graasprc file in the template repository.
  2. This file would have a key like:
{
  "replace": [
    {
      "location": "public/index.html",
      "from": "<title>Graasp App Starter</title>",
      "to": "<title>{{APP_NAME}}</title>"
    },
    {
      "location": "*.js",
      "from": "$MY_ENV_VAR",
      "to": "{{APP_SPECIFIC_ENV_VAR}}"
    },
  ]
}

As shown above, we could have the replacement strategy access variables set by the user in the CLI. Whether we use {{ or something else can be also configurable within the same .graasprc, to adapt to the different templates.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions