Skip to content

Commit

Permalink
refactor: package name update (#3)
Browse files Browse the repository at this point in the history
* refactor: renamed schematics package

* refactor: renamed schematics package

* refactor: renamed schematics package

* refactor: updated schematics package name in script
  • Loading branch information
field123 authored Dec 5, 2022
1 parent d21bf8a commit eb8e07e
Show file tree
Hide file tree
Showing 201 changed files with 51 additions and 42 deletions.
5 changes: 5 additions & 0 deletions .changeset/smart-buses-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@elasticpath/d2c-schematics": patch
---

Changed the name and scope of schematics package.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test": "turbo run test",
"test:watch": "turbo run test:watch",
"examples": "turbo run build --filter=@field123/epcc-schematics-cli... && yarn run scaffold:local:simple",
"scaffold:local:simple": "mkdir -p examples && cd ./examples && rimraf ./* && node ../packages/epcc-schematics-cli/dist/bin/schematics.js ../packages/schematics/dist:ep-new --dry-run=false --skip-install=true --skip-git=true --interactive=false --epcc-client-id=abc123 --epcc-client-secret=def456 --epcc-endpoint-url=api.moltin.com basic"
"scaffold:local:simple": "mkdir -p examples && cd ./examples && rimraf ./* && node ../packages/epcc-schematics-cli/dist/bin/schematics.js ../packages/d2c-schematics/dist:ep-new --dry-run=false --skip-install=true --skip-git=true --interactive=false --epcc-client-id=abc123 --epcc-client-secret=def456 --epcc-endpoint-url=api.moltin.com basic"
},
"devDependencies": {
"@changesets/cli": "^2.24.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @field123/schematics
# @elasticpath/d2c-schematics

## 0.4.2

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@field123/schematics",
"name": "@elasticpath/d2c-schematics",
"version": "0.4.2",
"description": "Elastic Path Commerce Cloud Schematics",
"description": "D2C Storefront Schematics for Elastic Path Commerce Cloud",
"repository": {
"type": "git",
"directory": "packages/schematics"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"description": "Package versions used by schematics in @field123/schematics.",
"description": "Package versions used by schematics in @elasticpath/d2c-schematics.",
"comment": "This file is needed so that dependencies are synced by Renovate.",
"private": true,
"dependencies": {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/epcc-schematics-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
### Patch Changes

- Updated dependencies [4d6bfa4]
- @field123/schematics@0.4.0
- @elasticpath/d2c-schematics@0.4.0

## 0.3.2

Expand Down
2 changes: 1 addition & 1 deletion packages/epcc-schematics-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"dependencies": {
"@angular-devkit/core": "^14.1.0",
"@angular-devkit/schematics": "^14.1.0",
"@field123/schematics": "^0.4.0",
"@elasticpath/d2c-schematics": "^0.4.0",
"ansi-colors": "4.1.3",
"inquirer": "8.2.4",
"symbol-observable": "4.0.0",
Expand Down
72 changes: 38 additions & 34 deletions packages/epcc-schematics-cli/src/schematics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,20 @@ import yargsParser, { camelCase, decamelize } from "yargs-parser"
* @param str The argument to parse.
* @return {{collection: string, schematic: (string)}}
*/
function parseSchematicName(str: string | null): {
function parseSchematicName(
str: string | null
): {
collection: string
schematic: string | null
} {
let collection = "@field123/schematics"
let collection = "@elasticpath/d2c-schematics"

let schematic = str
if (schematic?.includes(":")) {
const lastIndexOfColon = schematic.lastIndexOf(":")
;[collection, schematic] = [
schematic.slice(0, lastIndexOfColon),
schematic.substring(lastIndexOfColon + 1),
schematic.substring(lastIndexOfColon + 1)
]
}

Expand Down Expand Up @@ -74,18 +76,18 @@ function _listSchematics(
}

function _createPromptProvider(): schema.PromptProvider {
return (definitions) => {
return definitions => {
const questions: inquirer.QuestionCollection = definitions.map(
(definition) => {
definition => {
const question: inquirer.Question = {
name: definition.id,
message: definition.message,
default: definition.default,
default: definition.default
}

const validator = definition.validator
if (validator) {
question.validate = (input) => validator(input)
question.validate = input => validator(input)
}

switch (definition.type) {
Expand All @@ -97,16 +99,16 @@ function _createPromptProvider(): schema.PromptProvider {
type: definition.multiselect ? "checkbox" : "list",
choices:
definition.items &&
definition.items.map((item) => {
definition.items.map(item => {
if (typeof item == "string") {
return item
} else {
return {
name: item.label,
value: item.value,
value: item.value
}
}
}),
})
}
default:
return { ...question, type: definition.type }
Expand All @@ -122,7 +124,7 @@ function _createPromptProvider(): schema.PromptProvider {
export async function main({
args,
stdout = process.stdout,
stderr = process.stderr,
stderr = process.stderr
}: MainOptions): Promise<0 | 1> {
const { cliOptions, schematicOptions, _ } = parseArgs(args)
console.log("schematic options: ", schematicOptions, cliOptions)
Expand All @@ -131,11 +133,11 @@ export async function main({

/** Create the DevKit Logger used through the CLI. */
const logger = createConsoleLogger(!!cliOptions.verbose, stdout, stderr, {
info: (s) => s,
debug: (s) => s,
warn: (s) => colors.bold.yellow(s),
error: (s) => colors.bold.red(s),
fatal: (s) => colors.bold.red(s),
info: s => s,
debug: s => s,
warn: s => colors.bold.yellow(s),
error: s => colors.bold.red(s),
fatal: s => colors.bold.red(s)
})

if (cliOptions.help) {
Expand All @@ -145,8 +147,10 @@ export async function main({
}

/** Get the collection an schematic name from the first argument. */
const { collection: collectionName, schematic: schematicName } =
parseSchematicName(_.shift() || null)
const {
collection: collectionName,
schematic: schematicName
} = parseSchematicName(_.shift() || null)

console.log("collection and scehamtic: ", collectionName, schematicName)

Expand Down Expand Up @@ -174,7 +178,7 @@ export async function main({
force,
dryRun,
resolvePaths: [process.cwd(), __dirname],
schemaValidation: true,
schemaValidation: true
})

/** If the user wants to list schematics, we simply show all the schematic names. */
Expand Down Expand Up @@ -215,7 +219,7 @@ export async function main({
*
* This is a simple way to only show errors when an error occur.
*/
workflow.reporter.subscribe((event) => {
workflow.reporter.subscribe(event => {
nothingDone = false
// Strip leading slash to prevent confusion.
const eventPath = event.path.startsWith("/")
Expand Down Expand Up @@ -263,11 +267,11 @@ export async function main({
/**
* Listen to lifecycle events of the workflow to flush the logs between each phases.
*/
workflow.lifeCycle.subscribe((event) => {
workflow.lifeCycle.subscribe(event => {
if (event.kind == "workflow-end" || event.kind == "post-tasks-start") {
if (!error) {
// Flush the log queue and clean the error state.
loggingQueue.forEach((log) => logger.info(log))
loggingQueue.forEach(log => logger.info(log))
}

loggingQueue = []
Expand All @@ -276,10 +280,10 @@ export async function main({
})

// Show usage of deprecated options
workflow.registry.useXDeprecatedProvider((msg) => logger.warn(msg))
workflow.registry.useXDeprecatedProvider(msg => logger.warn(msg))

// Pass the rest of the arguments as the smart default "argv". Then delete it.
workflow.registry.addSmartDefaultProvider("argv", (schema) =>
workflow.registry.addSmartDefaultProvider("argv", schema =>
"index" in schema ? _[Number(schema["index"])] : _
)

Expand All @@ -304,7 +308,7 @@ export async function main({
options: { ...schematicOptions, skipGit, skipInstall },
allowPrivate: allowPrivate,
debug: debug,
logger: logger,
logger: logger
})
.toPromise()

Expand Down Expand Up @@ -380,7 +384,7 @@ const booleanArgs = [
"verbose",
"interactive",
"skip-install",
"skip-git",
"skip-git"
] as const

type ElementType<T extends ReadonlyArray<unknown>> = T extends ReadonlyArray<
Expand All @@ -398,18 +402,18 @@ interface Options {
/** Parse the command line. */
function parseArgs(args: string[]): Options {
const { _, ...options } = yargsParser(args, {
boolean: booleanArgs as unknown as string[],
boolean: (booleanArgs as unknown) as string[],
default: {
interactive: true,
debug: null,
"dry-run": null,
"dry-run": null
},
configuration: {
"dot-notation": false,
"boolean-negation": true,
"strip-aliased": true,
"camel-case-expansion": false,
},
"camel-case-expansion": false
}
})

console.log("options inside parseArgs: ", options, args)
Expand Down Expand Up @@ -440,9 +444,9 @@ function parseArgs(args: string[]): Options {
}

return {
_: _.map((v) => v.toString()),
_: _.map(v => v.toString()),
schematicOptions,
cliOptions,
cliOptions
}
}

Expand All @@ -466,8 +470,8 @@ function isTTY(): boolean {
if (require.main === module) {
const args = process.argv.slice(2)
main({ args })
.then((exitCode) => (process.exitCode = exitCode))
.catch((e) => {
.then(exitCode => (process.exitCode = exitCode))
.catch(e => {
throw e
})
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"./*/other-files/**/*",
"./*/project-files/**/*",
"./*/schematic-files/**/*",
"packages/schematics/node_modules",
"packages/d2c-schematics/node_modules",
"dist",
"**/node_modules/**/*",
"**/dist/**/*",
Expand Down

0 comments on commit eb8e07e

Please sign in to comment.