@stencil/cli 5.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,27 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019-present Drifty Co.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ -----------------------------------------
24
+ Third-party components, software, and/or libraries (collectively, "components")
25
+ are included under the licenses specified by their authors. For information
26
+ about these third-party licenses, refer to the separate legal notices governing
27
+ such components at NOTICE file at the top level of the package.
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Set NODE_ENV to production by default (matches legacy webpack bundling behavior)
4
+ // This suppresses development-only warnings from dependencies like PostCSS
5
+ process.env.NODE_ENV ??= 'production';
6
+
7
+ import { run } from '@stencil/cli';
8
+ import { createNodeLogger, createNodeSys } from '@stencil/core/sys/node';
9
+
10
+ run({
11
+ args: process.argv.slice(2),
12
+ logger: createNodeLogger(),
13
+ sys: createNodeSys(),
14
+ });
@@ -0,0 +1,153 @@
1
+ import * as _$_stencil_core_compiler0 from "@stencil/core/compiler";
2
+ import { LogLevel } from "@stencil/core/compiler";
3
+
4
+ //#region src/types.d.ts
5
+ /**
6
+ * Supported CLI task commands
7
+ */
8
+ type TaskCommand = 'build' | 'docs' | 'generate' | 'g' | 'help' | 'info' | 'prerender' | 'serve' | 'telemetry' | 'test' | 'version';
9
+ //#endregion
10
+ //#region src/config-flags.d.ts
11
+ /**
12
+ * All the Boolean options supported by the Stencil CLI
13
+ */
14
+ declare const BOOLEAN_CLI_FLAGS: readonly ["build", "cache", "checkVersion", "ci", "compare", "debug", "dev", "devtools", "docs", "e2e", "es5", "esm", "help", "log", "open", "prerender", "prerenderExternal", "prod", "profile", "serviceWorker", "screenshot", "serve", "skipNodeCheck", "spec", "ssr", "updateScreenshot", "verbose", "version", "watch", "all", "automock", "bail", "changedFilesWithAncestor", "clearCache", "clearMocks", "collectCoverage", "color", "colors", "coverage", "detectLeaks", "detectOpenHandles", "errorOnDeprecated", "expand", "findRelatedTests", "forceExit", "init", "injectGlobals", "json", "lastCommit", "listTests", "logHeapUsage", "noStackTrace", "notify", "onlyChanged", "onlyFailures", "passWithNoTests", "resetMocks", "resetModules", "restoreMocks", "runInBand", "runTestsByPath", "showConfig", "silent", "skipFilter", "testLocationInResults", "updateSnapshot", "useStderr", "watchAll", "watchman"];
15
+ /**
16
+ * All the Number options supported by the Stencil CLI
17
+ */
18
+ declare const NUMBER_CLI_FLAGS: readonly ["port", "maxConcurrency", "testTimeout"];
19
+ /**
20
+ * All the String options supported by the Stencil CLI
21
+ */
22
+ declare const STRING_CLI_FLAGS: readonly ["address", "config", "docsApi", "docsJson", "emulate", "root", "screenshotConnector", "cacheDirectory", "changedSince", "collectCoverageFrom", "coverageDirectory", "coverageThreshold", "env", "filter", "globalSetup", "globalTeardown", "globals", "haste", "moduleNameMapper", "notifyMode", "outputFile", "preset", "prettierPath", "resolver", "rootDir", "runner", "testEnvironment", "testEnvironmentOptions", "testFailureExitCode", "testNamePattern", "testResultsProcessor", "testRunner", "testSequencer", "testURL", "timers", "transform"];
23
+ declare const STRING_ARRAY_CLI_FLAGS: readonly ["collectCoverageOnlyFrom", "coveragePathIgnorePatterns", "coverageReporters", "moduleDirectories", "moduleFileExtensions", "modulePathIgnorePatterns", "modulePaths", "projects", "reporters", "roots", "selectProjects", "setupFiles", "setupFilesAfterEnv", "snapshotSerializers", "testMatch", "testPathIgnorePatterns", "testPathPattern", "testRegex", "transformIgnorePatterns", "unmockedModulePathPatterns", "watchPathIgnorePatterns"];
24
+ /**
25
+ * All the CLI arguments which may have string or number values
26
+ *
27
+ * `maxWorkers` is an argument which is used both by Stencil _and_ by Jest,
28
+ * which means that we need to support parsing both string and number values.
29
+ */
30
+ declare const STRING_NUMBER_CLI_FLAGS: readonly ["maxWorkers"];
31
+ /**
32
+ * All the CLI arguments which may have boolean or string values.
33
+ */
34
+ declare const BOOLEAN_STRING_CLI_FLAGS: readonly ["headless", "stats"];
35
+ /**
36
+ * All the LogLevel-type options supported by the Stencil CLI
37
+ *
38
+ * This is a bit silly since there's only one such argument atm,
39
+ * but this approach lets us make sure that we're handling all
40
+ * our arguments in a type-safe way.
41
+ */
42
+ declare const LOG_LEVEL_CLI_FLAGS: readonly ["logLevel"];
43
+ /**
44
+ * Given two types `K` and `T` where `K` extends `ReadonlyArray<string>`,
45
+ * construct a type which maps the strings in `K` as keys to values of type `T`.
46
+ *
47
+ * Because we use types derived this way to construct an interface (`ConfigFlags`)
48
+ * for which we want optional keys, we make all the properties optional (w/ `'?'`)
49
+ * and possibly null.
50
+ */
51
+ type ObjectFromKeys<K extends ReadonlyArray<string>, T> = { [key in K[number]]?: T | null };
52
+ /**
53
+ * Type containing the possible Boolean configuration flags, to be included
54
+ * in ConfigFlags, below
55
+ */
56
+ type BooleanConfigFlags = ObjectFromKeys<typeof BOOLEAN_CLI_FLAGS, boolean>;
57
+ /**
58
+ * Type containing the possible String configuration flags, to be included
59
+ * in ConfigFlags, below
60
+ */
61
+ type StringConfigFlags = ObjectFromKeys<typeof STRING_CLI_FLAGS, string>;
62
+ /**
63
+ * Type containing the possible String Array configuration flags. This is
64
+ * one of the 'constituent types' for `ConfigFlags`.
65
+ */
66
+ type StringArrayConfigFlags = ObjectFromKeys<typeof STRING_ARRAY_CLI_FLAGS, string[]>;
67
+ /**
68
+ * Type containing the possible numeric configuration flags, to be included
69
+ * in ConfigFlags, below
70
+ */
71
+ type NumberConfigFlags = ObjectFromKeys<typeof NUMBER_CLI_FLAGS, number>;
72
+ /**
73
+ * Type containing the configuration flags which may be set to either string
74
+ * or number values.
75
+ */
76
+ type StringNumberConfigFlags = ObjectFromKeys<typeof STRING_NUMBER_CLI_FLAGS, string | number>;
77
+ /**
78
+ * Type containing the configuration flags which may be set to either string
79
+ * or boolean values.
80
+ */
81
+ type BooleanStringConfigFlags = ObjectFromKeys<typeof BOOLEAN_STRING_CLI_FLAGS, boolean | string>;
82
+ /**
83
+ * Type containing the possible LogLevel configuration flags, to be included
84
+ * in ConfigFlags, below
85
+ */
86
+ type LogLevelFlags = ObjectFromKeys<typeof LOG_LEVEL_CLI_FLAGS, LogLevel>;
87
+ /**
88
+ * The configuration flags which can be set by the user on the command line.
89
+ * This interface captures both known arguments (which are enumerated and then
90
+ * parsed according to their types) and unknown arguments which the user may
91
+ * pass at the CLI.
92
+ *
93
+ * Note that this interface is constructed by extending `BooleanConfigFlags`,
94
+ * `StringConfigFlags`, etc. These types are in turn constructed from types
95
+ * extending `ReadonlyArray<string>` which we declare in another module. This
96
+ * allows us to record our known CLI arguments in one place, using a
97
+ * `ReadonlyArray<string>` to get both a type-level representation of what CLI
98
+ * options we support and a runtime list of strings which can be used to match
99
+ * on actual flags passed by the user.
100
+ */
101
+ interface ConfigFlags extends BooleanConfigFlags, StringConfigFlags, StringArrayConfigFlags, NumberConfigFlags, StringNumberConfigFlags, BooleanStringConfigFlags, LogLevelFlags {
102
+ task: TaskCommand | null;
103
+ args: string[];
104
+ knownArgs: string[];
105
+ unknownArgs: string[];
106
+ }
107
+ /**
108
+ * Helper function for initializing a `ConfigFlags` object. Provide any overrides
109
+ * for default values and off you go!
110
+ *
111
+ * @param init an object with any overrides for default values
112
+ * @returns a complete CLI flag object
113
+ */
114
+ declare const createConfigFlags: (init?: Partial<ConfigFlags>) => ConfigFlags;
115
+ //#endregion
116
+ //#region src/parse-flags.d.ts
117
+ /**
118
+ * Parse command line arguments into a structured `ConfigFlags` object
119
+ *
120
+ * @param args an array of CLI flags
121
+ * @returns a structured ConfigFlags object
122
+ */
123
+ declare const parseFlags: (args: string[]) => ConfigFlags;
124
+ //#endregion
125
+ //#region src/load-compiler.d.ts
126
+ type CoreCompiler = typeof _$_stencil_core_compiler0;
127
+ //#endregion
128
+ //#region src/run.d.ts
129
+ /**
130
+ * Main entry point for the Stencil CLI
131
+ *
132
+ * Take care of parsing CLI arguments, initializing various components needed
133
+ * by the rest of the program, and kicking off the correct task (build, test,
134
+ * etc).
135
+ *
136
+ * @param init initial CLI options
137
+ * @returns an empty promise
138
+ */
139
+ declare const run: (init: _$_stencil_core_compiler0.CliInitOptions) => Promise<any>;
140
+ /**
141
+ * Run a specified task
142
+ *
143
+ * @param coreCompiler an instance of a minimal, bootstrap compiler for running the specified task
144
+ * @param config a configuration for the Stencil project to apply to the task run
145
+ * @param task the task to run
146
+ * @param sys the {@link d.CompilerSystem} for interacting with the operating system
147
+ * @param flags the parsed CLI flags (owned by CLI, not passed to Core)
148
+ * @public
149
+ * @returns a void promise
150
+ */
151
+ declare const runTask: (coreCompiler: CoreCompiler, config: _$_stencil_core_compiler0.Config, task: TaskCommand, sys: _$_stencil_core_compiler0.CompilerSystem, flags?: ConfigFlags) => Promise<void>;
152
+ //#endregion
153
+ export { BOOLEAN_CLI_FLAGS, type ConfigFlags, type TaskCommand, createConfigFlags, parseFlags, run, runTask };