Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

Add 'package.json' templating #274

Open
vince-fugnitto opened this issue Nov 26, 2019 · 1 comment
Open

Add 'package.json' templating #274

vince-fugnitto opened this issue Nov 26, 2019 · 1 comment

Comments

@vince-fugnitto
Copy link
Member

Description

It'd be nice to utilize some form of templating for the various image's package.json in order to increase maintainability, and reduce duplication. This will make it much easier to customize the different images while keeping a standard base.

We could use a template/replacenent variable system to generate each application's package.json from an application-specific template. Replacement variables would be replaced by an arbitrary value for a given run, depending on some settings.

With such a mechanism, the resolutions block of each application's package.json could be defined in a single place and injected everywhere.

Something like this could help:
https://www.npmjs.com/package/envsub

Example
{
    "private": true,
    "theia": {
        "frontend": {
            "config": {
                "applicationName": "Theia Java Example",
                "preferences": {
                    %%PREFERENCES%%
                }
            }
        }
    },
    "dependencies": {
        %%DEPENDENCIES%%
        %%DEPENDENCIES_EXTRA%%
    },
    "resolutions": {
        %%RESOLUTIONS%%
    },
    "devDependencies": {
        "@theia/cli": "latest"
    }
}

And the replacement variable set to the following values.: 

%%RESOLUTIONS%%=
    "vscode-languageserver-protocol": "3.15.0-next.9",
    "vscode-languageserver-types": "3.15.0-next.5"

%%VERSION%%=latest

%%PREFERENCES%% =  
    "files.enableTrash": false
    "other.preference": "whatever"

# Assuming that recursive replacement variables are supported,
# we can maybe abstract the (latest/next) version like this:
%%$DEPENDENCIES%% = 
    "@theia/file-search": "%%VERSION%%",
    "@theia/git": "%%VERSION%%",
    "@theia/java": "%%VERSION%%",
    "@theia/json": "%%VERSION%%",
    "@theia/markers": "%%VERSION%%",
    "@theia/navigator": "%%VERSION%%",
    "@theia/outline-view": "%%VERSION%%",
    "@theia/preferences": "%%VERSION%%",
    "@theia/search-in-workspace": "%%VERSION%%",
    "@theia/terminal": "%%VERSION%%",
    "@theia/textmate-grammars": "%%VERSION%%",
    "@theia/tslint": "%%VERSION%%",
    "@theia/typescript": "%%VERSION%%",
    typescript": "latest"

# e.g. if flexibility needed we can define more categories
# of dependencies, concatenating them together in the end
%%DEPENDENCIES_EXTRA%% = 
    "@theia/docker": "%%VERSION%%",
    "someotherdep": "0.5.6"

Additional Information

@akosyakov
Copy link
Member

But it will make bad standalone examples?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants