Skip to content

Commit

Permalink
feat: update of deps incl. bug fixes (Node >= 20)
Browse files Browse the repository at this point in the history
  • Loading branch information
petermuessig committed Sep 3, 2024
1 parent d5ea70d commit 4c04617
Show file tree
Hide file tree
Showing 15 changed files with 3,777 additions and 4,584 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

39 changes: 0 additions & 39 deletions .eslintrc.json

This file was deleted.

5 changes: 1 addition & 4 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run hooks:commit-msg
npm run hooks:commit-msg
5 changes: 1 addition & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run hooks:pre-commit
npm run hooks:pre-commit
5 changes: 0 additions & 5 deletions .husky/skip.js

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The purpose of the `project` subgenerator is to guide you on your first steps wi
## Requirements

- Get [Node.js](https://nodejs.org/en/download/) (:warning: **version 18 or higher**)
- Get [Node.js](https://nodejs.org/en/download/) (:warning: **version 20 or higher**)

## Download and Installation

Expand Down
57 changes: 57 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import globals from "globals";
import js from "@eslint/js";

export default [
js.configs.recommended,
{
languageOptions: {
globals: {
...globals.node,
},
ecmaVersion: 2023,
sourceType: "module",
},
rules: {
"block-scoped-var": 1,
"keyword-spacing": 2,
"space-unary-ops": 2,
camelcase: 1,
"no-warning-comments": 1,
"no-debugger": 2,
"default-case": 1,
"no-unused-vars": 2,
"no-trailing-spaces": 2,
semi: [1, "always"],
quotes: [1, "double"],
"key-spacing": [
1,
{
beforeColon: false,
},
],
"comma-spacing": [
1,
{
before: false,
after: true,
},
],
"no-shadow": 2,
"no-irregular-whitespace": 2,
},
},
{
ignores: [
"eslint.config.js",

// Ignore node_files
"node_modules/",

// Ignore plugin generators (which are copies of the generators)
"plugin-generators/",

// Ignore test files
"test/",
],
},
];
19 changes: 19 additions & 0 deletions generators/app/defineGeneratorArguments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export const generatorArguments = {
generator: {
type: String,
required: false,
description: "Name of the generator to invoke (without the \x1b[33mgenerator-ui5-\x1b[0m prefix)",
},
subcommand: {
type: String,
required: false,
description: "Name of the subcommand to invoke (without the \x1b[33>mgenerator:\x1b[0m prefix)",
},
};

export default function defineGeneratorArguments(generator) {
Object.keys(generatorArguments).forEach((argName) => {
// register the argument for being displayed in the help
generator.argument(argName, generatorArguments[argName]);
});
}
119 changes: 119 additions & 0 deletions generators/app/defineGeneratorOptions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import path from "path";
import os from "os";
import getNPMConfig from "./getNPMConfig.js";

// the command line options of the generator
export const generatorOptions = {
pluginsHome: {
type: String,
description: "Home directory of the plugin generators",
default: path.join(os.homedir(), ".npm", "_generator-easy-ui5", "plugin-generators"),
hide: true, // shouldn't be needed
npmConfig: true,
},
plugins: {
type: Boolean,
alias: "p",
description: "List detailed information about installed plugin generators",
},
pluginsWithDevDeps: {
type: Boolean,
alias: "dev",
description: "Installs the plugin generators with dev dependencies (compat mode)",
},
ghBaseUrl: {
type: String,
description: "Base URL for the Octokit API (defaults to https://api.github.com if undefined)",
hide: true, // shouldn't be needed
npmConfig: true,
},
ghAuthToken: {
type: String,
description: "GitHub authToken to optionally access private generator repositories",
npmConfig: true,
},
ghOrg: {
type: String,
description: "GitHub organization to lookup for available generators",
default: "ui5-community",
hide: true, // we don't want to recommend to use this option
},
ghThreshold: {
type: Number,
default: 100,
hide: true, // shouldn't be needed
},
subGeneratorPrefix: {
type: String,
description: "Prefix used for the lookup of the available generators",
default: "generator-ui5-",
hide: true, // we don't want to recommend to use this option
},
addGhBaseUrl: {
type: String,
description: "Base URL for the Octokit API for the additional generators (defaults to https://api.github.com if undefined)",
hide: true, // shouldn't be needed
npmConfig: true,
},
addGhOrg: {
type: String,
description: "GitHub organization to lookup for additional available generators",
hide: true, // we don't want to recommend to use this option
npmConfig: true,
},
addSubGeneratorPrefix: {
type: String,
description: "Prefix used for the lookup of the additional available generators",
default: "generator-",
hide: true, // we don't want to recommend to use this option
npmConfig: true,
},
embed: {
type: Boolean,
description: "Embeds the selected plugin generator",
hide: true, // shouldn't be needed
},
list: {
type: Boolean,
description: "List the available subcommands of the generator",
},
skipUpdate: {
type: Boolean,
description: "Skip the update of the plugin generator",
},
forceUpdate: {
type: Boolean,
description: "Force the update of the plugin generator",
},
offline: {
type: Boolean,
alias: "o",
description: "Running easy-ui5 in offline mode",
},
verbose: {
type: Boolean,
description: "Enable detailed logging",
},
next: {
type: Boolean,
description: "Preview the next mode to consume subgenerators from bestofui5.org",
},
skipNested: {
type: Boolean,
description: "Skips the nested generators and runs only the first subgenerator",
},
};

export default function defineGeneratorOptions(generator) {
Object.keys(generatorOptions).forEach((optionName) => {
const initialValue = generator.options[optionName];
// register the option for being displayed in the help
generator.option(optionName, generatorOptions[optionName]);
const defaultedValue = generator.options[optionName];
if (generatorOptions[optionName].npmConfig) {
// if a value is set, use the set value (parameter has higher precedence than npm config)
// => generator.option(...) applies the default value to generator.options[...] used as last resort
generator.options[optionName] = initialValue || getNPMConfig(optionName) || defaultedValue;
}
});
}
16 changes: 16 additions & 0 deletions generators/app/detectProxySettings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import getNPMConfig from "./getNPMConfig.js";

// apply proxy settings to GLOBAL_AGENT to support the proxy configuration for node-fetch using the GLOBAL_AGENT
// ==> the configuration is derived from the environment variables ([GLOBAL_AGENT_](HTTP|HTTPS|NO)_PROXY) and the npm config ((http|https|no)-proxy)
// ==> empty values will allow to override the more general proxy settings and make the proxy value undefined
let HTTP_PROXY, HTTPS_PROXY, NO_PROXY;
if (global?.GLOBAL_AGENT) {
HTTP_PROXY = process.env.GLOBAL_AGENT_HTTP_PROXY ?? process.env.HTTP_PROXY ?? process.env.http_proxy ?? getNPMConfig("http-proxy", "") ?? getNPMConfig("proxy", "");
global.GLOBAL_AGENT.HTTP_PROXY = HTTP_PROXY = HTTP_PROXY || global.GLOBAL_AGENT.HTTP_PROXY;
HTTPS_PROXY = process.env.GLOBAL_AGENT_HTTPS_PROXY ?? process.env.HTTPS_PROXY ?? process.env.https_proxy ?? getNPMConfig("https-proxy", "") ?? getNPMConfig("proxy", "");
global.GLOBAL_AGENT.HTTPS_PROXY = HTTPS_PROXY = HTTPS_PROXY || global.GLOBAL_AGENT.HTTPS_PROXY;
NO_PROXY = process.env.GLOBAL_AGENT_NO_PROXY ?? process.env.NO_PROXY ?? process.env.no_proxy ?? getNPMConfig("no-proxy", "");
global.GLOBAL_AGENT.NO_PROXY = NO_PROXY = NO_PROXY || global.GLOBAL_AGENT.NO_PROXY;
}

export { HTTP_PROXY, HTTPS_PROXY, NO_PROXY };
12 changes: 12 additions & 0 deletions generators/app/getNPMConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import libnpmconfig from "libnpmconfig";

// helper to retrieve config entries from npm
// --> npm config set easy-ui5_addGhOrg XYZ
let npmConfig;

export default function getNPMConfig(configName, prefix = "easy-ui5_") {
if (!npmConfig) {
npmConfig = libnpmconfig.read();
}
return npmConfig && npmConfig[`${prefix}${configName}`];
}
Loading

0 comments on commit 4c04617

Please sign in to comment.