Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI configuration file #1996

Closed
6 tasks done
tomrav opened this issue Aug 8, 2021 · 1 comment · Fixed by #2086
Closed
6 tasks done

CLI configuration file #1996

tomrav opened this issue Aug 8, 2021 · 1 comment · Fixed by #2086
Assignees
Labels
tooling CLI, stylable-scripts boilerplate

Comments

@tomrav
Copy link
Collaborator

tomrav commented Aug 8, 2021

Description

Stylable currently supports one build flow.
We want the ability to structure a program into smaller pieces and give the ability to share configuration between them.

When working with multi packages project that uses Stylable CLI, you will need to call stc from each package and specify the configuration inline. For example, stc --outDir dist.
The solution that we are looking for is that the user will configure his project in one place (regardless of whether it is one package or many).

Current main issues

  • Projects are running stc multiple times and not once.
  • There is no watch mode that understands the dependency graph and builds them in the correct package order.

Goals

  • Parsing configuration from a file js or json for the example - stylable.config.js. Then the user can configure his project easily and use presets or share code (it also can be typed).
  • Give the option to hook into process life cycles.
  • Using one configuration from the root for the whole multi-package project.
    We can have a field named projects which can be an array of package names or a record that the key represents a request that can be a package name or a matching pattern and the value can be preset, presets, partial configuration, or object with preset and configuration override.
export type Presets = Record<string, PartialBuildOptions>;

export type Projects =
    | Array<string | [string, ProjectEntryValues]>
    | Record<string, ProjectEntryValues>;

export interface MultipleProjectsConfig extends Partial<SingleProjectConfig> {
    presets?: Presets;
    projects: Projects;
    projectsOptions?: {
        resolveRequests?: ResolveRequests;
    };
}


export type ProjectEntryValue<T extends string> =
    | T
    | PartialBuildOptions
    | {
          preset?: T;
          presets?: Array<T>;
          options: PartialBuildOptions;
      };

export type ProjectEntryValues<T extends string> =
    | ProjectEntryValue<T>
    | Array<ProjectEntryValue<T>>;

By default the packages must be under workspaces field in the root package json.

  • As stated above, we will give the option to declare presets available in the project.
    We could also provide common presets that will have the options configured in the documentation for the user to see and use. For example, like stcss-lib, css-lib, css-in-js-lib, ssr, etc.

  • The user can provide his own resolve requests method.

Preset examples:

  • Usages in projects
{
    "presets": {
        "stcss": { "dts": true, "extension": "stcss" }
    },
    "projects": {
        "lib": "stcss"
    },
}
  • Usage in projects with override
{
    "presets": {
        "stcss": { "dts": true, "extension": "stcss" }
    },
    "projects": {
        "lib": {
        	"preset": "stcss",
		"options": {
			"dts": false
		}
	}
    }
}

Options resolution order

- default options
- config file
  - root options
  - presets
  - project override
- cli args override

Tasks:

  • - parse stylable config file. (bde9849)
  • - handle multilpe dependencies and build them by topological sort.
  • - support watch for multiple depenedencies.
  • - handle presets.
  • - support watch for multiple presets.
  • - add to documentaion.

Tags

#tooling

Related issues

#1813 #2001

Dependencies

@tomrav tomrav added research research for future tasks tooling CLI, stylable-scripts boilerplate :size(medium) Effort estimate: small labels Aug 8, 2021
@tzachbon tzachbon self-assigned this Aug 15, 2021
@tzachbon
Copy link
Contributor

tzachbon commented Aug 15, 2021

Edit: moved content to top

@barak007 barak007 changed the title Support CLI mono-repo configurations CLI configuration file Aug 23, 2021
@tzachbon tzachbon linked a pull request Sep 12, 2021 that will close this issue
@tomrav tomrav added this to Stylable Dec 14, 2021
@tomrav tomrav moved this to Active in Stylable Dec 14, 2021
@tomrav tomrav removed research research for future tasks :size(medium) Effort estimate: small labels Dec 19, 2021
@tomrav tomrav linked a pull request Dec 22, 2021 that will close this issue
19 tasks
@tomrav tomrav moved this from ▶️ In Progress to ⏸️ Paused in Stylable Dec 22, 2021
@tomrav tomrav moved this from ⏸️ Paused to ▶️ In Progress in Stylable Dec 28, 2021
@tzachbon tzachbon moved this from ▶️ In Progress to 🎬 Ready for Work in Stylable Dec 30, 2021
@tzachbon tzachbon moved this from 🎬 Ready for Work to ▶️ In Progress in Stylable Jan 4, 2022
@tzachbon tzachbon moved this from ▶️ In Progress to ⏸️ Paused in Stylable Jan 4, 2022
@tomrav tomrav removed the status in Stylable Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tooling CLI, stylable-scripts boilerplate
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants