@patternfly/create-element
Advanced tools
Comparing version 1.0.0-next.8 to 1.0.0-next.9
@@ -50,2 +50,12 @@ import Case from "case"; | ||
}; | ||
function isMonorepoFileKey(key) { | ||
switch (key) { | ||
case "package" /* package */: | ||
case "cemConfig" /* cemConfig */: | ||
case "tsconfig" /* tsconfig */: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
const getFilePathsRelativeToPackageDir = memoize((options) => ({ | ||
@@ -106,2 +116,5 @@ cemConfig: "custom-elements-manifest.config.js", | ||
async function writeComponentFile(key, options) { | ||
if (!options.monorepo && isMonorepoFileKey(key)) { | ||
return; | ||
} | ||
const PATH = getOutputFilePath(key, options); | ||
@@ -140,3 +153,4 @@ const TEMPLATE = await getTemplate(key); | ||
} | ||
const { stderr, stdout } = await execa("npm", ["run", "analyze", "--prefix", getComponentAbsPath(options)], { | ||
const monorepoArgs = !options.monorepo ? [] : ["--prefix", getComponentAbsPath(options)]; | ||
const { stderr, stdout } = await execa("npm", ["run", "analyze", ...monorepoArgs], { | ||
all: true, | ||
@@ -174,5 +188,7 @@ cwd: options.directory | ||
await analyzeElement(options); | ||
await updateTsconfig(options); | ||
await execaCommand("npm install"); | ||
if (options.monorepo) { | ||
await updateTsconfig(options); | ||
await execaCommand("npm install"); | ||
} | ||
} | ||
} |
@@ -5,2 +5,3 @@ export interface BaseOptions { | ||
overwrite: boolean; | ||
monorepo: boolean; | ||
} | ||
@@ -7,0 +8,0 @@ export interface AppOptions extends BaseOptions { |
12
main.js
@@ -5,4 +5,10 @@ import { generateElement } from "./generator/element.js"; | ||
import prompts from "prompts"; | ||
import { readJson } from "./generator/files.js"; | ||
import { join } from "node:path"; | ||
const ERR_BAD_CE_TAG_NAME = "Custom element tag names must contain a hyphen (-)"; | ||
const b = Chalk.cyanBright; | ||
async function isMonorepo() { | ||
const { workspaces } = await readJson(join(process.cwd(), "package.json")); | ||
return !!workspaces; | ||
} | ||
function banner() { | ||
@@ -46,3 +52,3 @@ console.log(`${Chalk.cyan(` | ||
}, { | ||
type: () => !options?.scope && "text", | ||
type: () => !options?.scope && options?.monorepo ? "text" : false, | ||
name: "scope", | ||
@@ -76,2 +82,6 @@ message: "What is the package's NPM scope?", | ||
description: "Overwrite files without prompting" | ||
}).option("monorepo", { | ||
type: "boolean", | ||
default: await isMonorepo(), | ||
description: "Generate an npm package for the element" | ||
}).help().check(({ name }) => { | ||
@@ -78,0 +88,0 @@ if (typeof name === "string" && !name.includes("-")) { |
{ | ||
"name": "@patternfly/create-element", | ||
"version": "1.0.0-next.8", | ||
"version": "1.0.0-next.9", | ||
"description": "Scaffold web components monorepos based on PatternFly Elements", | ||
@@ -5,0 +5,0 @@ "author": "Benny Powers <bennyp@redhat.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19469
443