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

Dependency updates iteration 1 #1311

Merged
merged 35 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
829c8bc
chore(*): update fs-extra & types to latest
jackofdiamond5 Aug 27, 2024
a89343c
chore(*): update browser-sync & lite-server to latest
jackofdiamond5 Aug 27, 2024
2aafd5e
chore(cli): bump types/node, nyc, fs-extra, types/fs-extra, browser-s…
jackofdiamond5 Aug 27, 2024
2f4e7ae
chore(root; cli): update typescript-json-schema, remove deprecated op…
jackofdiamond5 Aug 27, 2024
bc905a2
chore(root; cli): update through2, source-map-support
jackofdiamond5 Aug 27, 2024
5c233c0
chore(cli): bump ts-node
jackofdiamond5 Aug 27, 2024
c84b473
chore(root; cli): bump chalk, coveralls
jackofdiamond5 Aug 27, 2024
89a73e6
chore(root;cli): bump glob, resolve, rxjs, handlebars
jackofdiamond5 Aug 27, 2024
c15ed09
chore(cli): bump yargs
jackofdiamond5 Aug 28, 2024
eca83f3
refactor(cli): update quickstart command; introduce strict types
jackofdiamond5 Aug 28, 2024
787b358
refactor(cli): update new command; introduce strict types
jackofdiamond5 Aug 30, 2024
82ead59
refactor(cli): rework command chaining; update add command; introduce…
jackofdiamond5 Aug 30, 2024
f2ffa0a
refactor(cli): update build command; introduce strict types
jackofdiamond5 Aug 30, 2024
db719d9
refactor(cli): update start command; introduce strict types
jackofdiamond5 Aug 30, 2024
9ad3b48
refactor(cli): update generate command; introduce strict types
jackofdiamond5 Sep 2, 2024
28336d9
refactor(cli): update config command; introduce strict types
jackofdiamond5 Sep 2, 2024
bd6b043
refactor(cli_: update doc command; introduce strict types
jackofdiamond5 Sep 2, 2024
734b3e0
refactor(cli): update test command; introduce strict types
jackofdiamond5 Sep 3, 2024
768d487
refactor(cli): update list command; introduce strict types
jackofdiamond5 Sep 3, 2024
5af7188
refactor(cli): update upgrade command; introduce strict types
jackofdiamond5 Sep 3, 2024
b769f6e
refactor(cli): setup help command
jackofdiamond5 Sep 4, 2024
40bbccf
refactor(execute): provide args to cli.run
jackofdiamond5 Sep 4, 2024
c62098e
refactor(cli): disable usage msg on all commands
jackofdiamond5 Sep 4, 2024
67cb21e
refactor(cli): check for help on quickstart; use correct upgrade comm…
jackofdiamond5 Sep 4, 2024
2dde833
test(help): introduce tests for all commands
jackofdiamond5 Sep 4, 2024
e1bc4ca
refactor(cli): export commands from an index
jackofdiamond5 Sep 4, 2024
25ab771
docs(cli): add docs for new types
jackofdiamond5 Sep 4, 2024
f5a08b8
refactor(workflows): remove 18.x for node ci
jackofdiamond5 Sep 4, 2024
8fc6d51
refactor(workflows): generate coverage for 20.x
jackofdiamond5 Sep 4, 2024
ef74720
refactor(*): use report-dir for nyc report
jackofdiamond5 Sep 4, 2024
065983a
refactor(root; cli): remove fs-extra
jackofdiamond5 Sep 4, 2024
d965429
refactor(cli): run prompt session when no command matches input
jackofdiamond5 Sep 9, 2024
2c77e4c
Merge remote-tracking branch 'remotes/origin/master' into bpenkov/dep…
jackofdiamond5 Sep 9, 2024
0b01772
refactor(cli): do not trigger prompt session on help request
jackofdiamond5 Sep 9, 2024
7b7fd67
refactor(config): clean up redundancies
jackofdiamond5 Sep 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [18.x, 20.x]
node-version: [20.x]
steps:
- name: Checkout
uses: actions/checkout@v3 #set credentials for every repository on the computer --global, so `New command` CLI tests pass
Expand All @@ -31,10 +31,10 @@ jobs:
yarn config set scripts-prepend-node-path auto
yarn test
- name: Generate coverage
if: matrix.node-version == '18.x'
if: matrix.node-version == '20.x'
run: yarn coverage
- name: Publish to coveralls.io
if: matrix.node-version == '18.x'
if: matrix.node-version == '20.x'
uses: coverallsapp/github-action@v1.1.2
with:
github-token: ${{ github.token }}
22 changes: 10 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"pretest": "npm run lint && npm run build",
"test": "nyc npm run jasmine",
"jasmine": "node spec/jasmine-runner.js",
"coverage": "nyc report --dir coverage lcov",
"coverage": "nyc report --report-dir",
"lint": "eslint -c .eslintrc.json ./**/*.ts",
"config-schema": "typescript-json-schema packages/core/types/Config.ts Config -o packages/core/config/Config.schema.json"
},
Expand Down Expand Up @@ -57,37 +57,35 @@
"all": true
},
"dependencies": {
"handlebars": "4.7.7"
"handlebars": "4.7.8"
},
"devDependencies": {
"@types/fs-extra": "^3.0.3",
"@types/inquirer": "0.0.35",
"@types/jasmine": "3.3.9",
"@types/minimatch": "^5.1.2",
"@types/node": "^20.12.3",
"@typescript-eslint/eslint-plugin": "^7.5.0",
"@typescript-eslint/parser": "^7.5.0",
"browser-sync": "^2.26.3",
"coveralls": "^3.0.0",
"browser-sync": "^3.0.2",
"coveralls": "^3.1.1",
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-unicorn": "^52.0.0",
"fs-extra": "^3.0.1",
"glob": "^7.1.2",
"glob": "^11.0.0",
"inquirer": "^6.4.1",
"jasmine": "3.5.0",
"jasmine-spec-reporter": "^4.2.1",
"lerna": "^3.16.4",
"lerna-changelog": "^0.8.2",
"lite-server": "^2.4.0",
"nyc": "^13.1.0",
"resolve": "^1.6.0",
"source-map-support": "^0.5.4",
"lite-server": "^2.6.1",
"nyc": "^17.0.0",
"resolve": "^1.22.8",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.2",
"tslint": "^5.11.0",
"typescript": "~5.4.3",
"typescript-json-schema": "^0.63.0"
"typescript-json-schema": "^0.65.1"
},
"workspaces": [
"packages/*"
Expand Down
21 changes: 11 additions & 10 deletions packages/cli/bin/execute.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
#!/usr/bin/env node
var fs = require("fs");
var inquirer = require('inquirer');
var projectConfiguration = {};
var resolve = require('resolve');
var path = require('path');
const fs = require("fs");
const resolve = require("resolve");
const path = require("path");
const { hideBin } = require("yargs/helpers");

const args = hideBin(process.argv);

//execute -g igniteui-cli in case there is no project installed, else resolve to the local one
resolve('igniteui-cli', { basedir: process.cwd() }, function (err, res) {
var cli;
resolve("igniteui-cli", { basedir: process.cwd() }, function (err, res) {
let cli;
if (res && res.indexOf(process.cwd()) > -1) {
var localVersion = require(path.join(process.cwd(), 'node_modules/igniteui-cli/package.json'))['version'];
var globalVersion = require(path.join(__dirname, '../package.json'))['version'];
const localVersion = require(path.join(process.cwd(), "node_modules/igniteui-cli/package.json"))["version"];
const globalVersion = require(path.join(__dirname, "../package.json"))["version"];
if (globalVersion !== localVersion) {
console.log("Different igniteui-cli global and local version");
}
cli = require(res);
} else {
cli = require("../lib/cli");
}
cli.run();
cli.run(args);
});
2 changes: 1 addition & 1 deletion packages/cli/lib/PromptSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class PromptSession extends BasePromptSession {

protected async upgradePackages() {
upgrade.templateManager = this.templateManager as TemplateManager;
await upgrade.upgrade({ skipInstall: true });
await upgrade.upgrade({ skipInstall: true, _: ["upgrade"], $0: "upgrade" });
}

/**
Expand Down
198 changes: 103 additions & 95 deletions packages/cli/lib/cli.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import { App, GoogleAnalytics, Util } from "@igniteui/cli-core";
import * as yargs from "yargs";
import { default as add } from "./commands/add";
import { default as build } from "./commands/build";
import { default as config } from "./commands/config";
import { default as doc } from "./commands/doc";
import { default as generate } from "./commands/generate";
import { default as list } from "./commands/list";
import { default as newCommand } from "./commands/new";
import { default as quickstart } from "./commands/quickstart";
import { default as start } from "./commands/start";
import { default as test } from "./commands/test";
import { default as upgrade } from "./commands/upgrade";
import {
add,
ADD_COMMAND_NAME,
ALL_COMMANDS,
build,
config,
doc,
generate,
list,
newCommand,
quickstart,
QUICKSTART_COMMAND_NAME,
start,
test,
upgrade,
} from './commands';
import { PromptSession } from "./PromptSession";
import {TemplateManager} from "./TemplateManager";
import { TemplateManager } from "./TemplateManager";

process.title = "Ignite UI CLI";

Expand All @@ -24,14 +29,12 @@ function logHelp() {
}

export async function run(args = null) {
// we are subscribing on process.exit to catch when help is executed
process.on("exit", logHelp);
App.initialize();

const templateManager = new TemplateManager();

newCommand.template = templateManager;
newCommand.builder.framework.choices = templateManager.getFrameworkIds();
newCommand.addChoices(templateManager.getFrameworkIds());
newCommand.templateManager = templateManager;
add.templateManager = templateManager;
build.templateManager = templateManager;
start.templateManager = templateManager;
Expand All @@ -40,90 +43,95 @@ export async function run(args = null) {
upgrade.templateManager = templateManager;

const yargsModule = args ? yargs(args) : yargs;
await yargsModule
.scriptName("") // prevent the addition of the name of the executing script in the usage output
.usage("") // do not show any usage instructions before the commands list
.command(quickstart)
.command(newCommand)
.command(add)
.command(build)
.command(start)
.command(generate)
.command(config)
.command(doc)
.command(test)
.command(list)
.command(upgrade)
.version(false) // disable built-in `yargs.version` to override it with our custom option
.options({
version: {
alias: "v",
description: "Show current Ignite UI CLI version",
global: true,
type: "boolean"
}
})
.options({ // testMode option to allow the addition of all templates at once
testMode: {
default: false,
type: "boolean",
hidden: true
}
})
.middleware((argv) => {
// invoked after parsing and before the `yargsModule.parseAsync` callback
const command = argv._[0];
if (command === ADD_COMMAND_NAME && !add.check(argv)) {
argv.skipExecution = true;
yargsModule.showHelp();
}
},
false // setting this to `true` is supposed to exec the middleware after parsing and before arg validation
// but in reality it also does not trigger the command's handler (╯°□°)╯︵ ┻━┻
)
.help().alias("help", "h")
.parseAsync(
args, // the args to parse to argv
{}, // docs say context to pass in to handlers, but nuh-uh, it's just garbage
async (err, argv, output) => {
// `argv._` are the positional arguments passed in to the script
const command = argv._[0];

if (err) {
Util.error(`The ${command} command threw error - ${err.name}`, "red");
Util.error(`Message: ${err.message}`, "red");
if (err.stack) {
Util.error(`Stack: ${err.stack}`, "red");
}
process.exit(1);
}

const argv = yargsModule
.command(quickstart)
.command(newCommand)
.command(add)
.command(build)
.command(start)
.command(generate)
.command(config)
.command(doc)
.command(test)
.command(list)
.command(upgrade)
.options({
version: {
alias: "v",
description: "Show current Ignite UI CLI version",
global: true,
type: "boolean"
}
})
.help().alias("help", "h")
.argv;
const helpRequest = argv.h || argv.help;
if (helpRequest) {
logHelp();
}

// unsubscribing from process.exit. If `help` was executed we should not reach here
process.removeListener("exit", logHelp);
if (command === QUICKSTART_COMMAND_NAME && !helpRequest) {
Util.log("quickstart Created");
return;
}

if (argv.version) {
Util.showVersion(__dirname + "/../ignite-ui-cli.txt");
return;
}
// since we are providing a custom callback to `yargsModule.parseAsync`, we need to handle the output as well
// ref - https://yargs.js.org/docs/#api-reference-parseargs-context-parsecallback
if (output) {
Util.log(output);
}

const command = argv._[0];
if (argv.version) {
Util.showVersion(__dirname + "/../ignite-ui-cli.txt");
return;
}

// internal testing only
/* istanbul ignore next */
App.testMode = !!argv.testMode;
// internal testing only
/* istanbul ignore next */
App.testMode = !!argv.testMode;

switch (command) {
case "new":
await newCommand.execute(argv);
break;
case "quickstart":
await quickstart.execute(argv);
Util.log("quickstart Created");
break;
case "add":
if (add.check(argv)) {
await add.execute(argv);
} else {
yargsModule.showHelp();
return;
if (!helpRequest && !ALL_COMMANDS.has(command?.toString())) {
Util.log("Starting Step by step mode.", "green");
Util.log("For available commands, stop this execution and use --help.", "green");
const prompts = new PromptSession(templateManager);
prompts.start();
}
}
break;
case "g":
case "generate":
await generate.template(argv);
break;
case "build":
await build.execute(argv);
break;
case "config":
break;
case "doc":
await doc.execute(argv);
break;
case "test":
await test.execute(argv);
break;
case "start":
await start.execute(argv);
break;
case "l":
case "list":
list.execute(argv);
break;
case "upgrade-packages":
await upgrade.execute(argv);
break;
default:
Util.log("Starting Step by step mode.", "green");
Util.log("For available commands, stop this execution and use --help.", "green");
const prompts = new PromptSession(templateManager);
prompts.start();
break;
}
);
}
22 changes: 10 additions & 12 deletions packages/cli/lib/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@ import {
AddTemplateArgs, GoogleAnalytics, PackageManager,
ProjectConfig, ProjectLibrary, Template, Util
} from "@igniteui/cli-core";
import { TemplateManager } from "../TemplateManager";
import { PromptSession } from "./../PromptSession";
import { AddCommandType, PositionalArgs } from "./types";
import { ArgumentsCamelCase } from "yargs";

let command: {
[name: string]: any,
templateManager: TemplateManager,
execute: (argv: any) => Promise<void>,
addTemplate: (name: string, template: Template, options?: AddTemplateArgs) => Promise<boolean>
};
// tslint:disable:object-literal-sort-keys
command = {
const command: AddCommandType = {
command: "add [template] [name]",
desc: "adds template by its ID",
describe: "adds template by its ID",
templateManager: null,
builder: {
"template": {
Expand Down Expand Up @@ -42,13 +36,17 @@ command = {
global: true
}
},
check: argv => {
check: (argv: ArgumentsCamelCase<PositionalArgs>) => {
if ((!argv.name && argv.template) || (argv.name && !argv.template)) {
return false;
}
return true;
},
async execute(argv) {
async handler(argv: ArgumentsCamelCase<PositionalArgs>) {
if (argv.skipExecution) {
return;
}

GoogleAnalytics.post({
t: "screenview",
cd: "Add"
Expand Down
Loading
Loading