Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 1 addition & 3 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ jobs:
ref: release
- uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '24'
registry-url: 'https://registry.npmjs.org'
# Ensure npm 11.5.1 or later is installed
- run: npm install -g npm@latest
- run: npm i
- run: npm run build
- run: npm publish
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ jobs:
- run: docker pull postgres
- uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '24'
registry-url: 'https://registry.npmjs.org'
- run: npm i -g npm@latest
- run: npm i -g @angular/cli@20 zibri-cli @loopback/cli@7 @nestjs/cli@11 create-vite@6 create-storybook@9.1.20
- run: npm i -g @angular/cli@20 zibri-cli @loopback/cli@7 @nestjs/cli@12 create-vite@6 create-storybook@9.1.20
- run: npm i
- run: npm run build
- run: npm run test
3,049 changes: 1,629 additions & 1,420 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "monux-cli",
"version": "2.5.7",
"version": "2.5.8",
"license": "MIT",
"main": "index.js",
"engines": {
Expand Down Expand Up @@ -54,7 +54,7 @@
"@angular/common": "^20.2.1",
"@faker-js/faker": "^9.0.3",
"@jest/globals": "^30.3.0",
"@nestjs/common": "^11.1.18",
"@nestjs/common": "^12.1.2",
"@types/death": "^1.1.5",
"@types/figlet": "^1.7.0",
"@types/js-yaml": "^4.0.9",
Expand Down
2 changes: 1 addition & 1 deletion src/angular/angular-utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ describe('AngularUtilities', () => {
await AngularUtilities.setupPwa(mockConstants.ANGULAR_APP_DIR, mockConstants.ANGULAR_APP_NAME);

expect(cpExecSyncMock).toHaveBeenCalledTimes(1);
expect(cpExecSyncMock).toHaveBeenCalledWith(`cd ${mockConstants.ANGULAR_APP_DIR} && npx @angular/cli@20 add @angular/pwa@20 --skip-confirmation`);
expect(cpExecSyncMock).toHaveBeenCalledWith(`cd ${mockConstants.ANGULAR_APP_DIR} && npx --yes @angular/cli@20 add @angular/pwa@20 --skip-confirmation`);
expect(npmInstallMock).toHaveBeenCalledTimes(1);
expect(npmInstallMock).toHaveBeenCalledWith(mockConstants.ANGULAR_APP_NAME, [NpmPackage.NGX_PWA]);

Expand Down
2 changes: 1 addition & 1 deletion src/angular/angular.utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ export abstract class AngularUtilities {
* @param options - Options for running the command.
*/
static async runCommand(directory: Path, command: AngularCliCommands, options: AngularCliOptions<typeof command>): Promise<void> {
await CPUtilities.exec(`cd ${directory} && npx @angular/cli@${this.CLI_VERSION} ${command} ${optionsToCliString(options)}`);
await CPUtilities.exec(`cd ${directory} && npx --yes @angular/cli@${this.CLI_VERSION} ${command} ${optionsToCliString(options)}`);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { afterEach, beforeEach, describe, expect, jest, test } from '@jest/globals';

import { AddAngularLibraryCommand } from './add-angular-library.command';
import { FileMockUtilities, getMockConstants, MAX_ADD_TIME, MockConstants, inquireMock } from '../../../__testing__';
import { InquirerUtilities } from '../../../encapsulation';
import { AddConfiguration, AddType } from '../models';
import { AddAngularLibraryCommand } from './add-angular-library.command';

const mockConstants: MockConstants = getMockConstants('add-angular-library-command');

Expand Down
18 changes: 13 additions & 5 deletions src/commands/add/add-nest/add-nest.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ export class AddNestCommand extends BaseAddCommand<AddNestConfiguration> {
EslintUtilities.setupProjectEslint(root, true, 'tsconfig.json'),
this.setupTsConfig(config.name),
this.updatePackageJson(config.name),
this.updateNestCliJson(root),
this.setupSwagger(root, config.name),
DockerUtilities.addServiceToCompose(
{
Expand All @@ -124,8 +123,7 @@ export class AddNestCommand extends BaseAddCommand<AddNestConfiguration> {
false,
config.subDomain
),
this.createDockerfile(root, config),
this.createWebpackConfig(root)
this.createDockerfile(root, config)
]);

await NpmUtilities.install(
Expand Down Expand Up @@ -231,7 +229,9 @@ export class AddNestCommand extends BaseAddCommand<AddNestConfiguration> {
'--skip-git': true,
'--language': 'TS',
'--package-manager': 'npm',
'--skip-install': true
'--type': 'cjs',
'--skip-install': true,
'--no-observe': true
}
);
const newProject: WorkspaceProject = await WorkspaceUtilities.findProjectOrFail(config.name, getPath('.'));
Expand Down Expand Up @@ -270,10 +270,18 @@ export class AddNestCommand extends BaseAddCommand<AddNestConfiguration> {
sourceMap: undefined,
skipLibCheck: undefined,
noImplicitAny: undefined,
noFallthroughCasesInSwitch: undefined
noFallthroughCasesInSwitch: undefined,
rootDir: undefined
}
}
);

const project: WorkspaceProject = await WorkspaceUtilities.findProjectOrFail(projectName, getPath('.'));
const tsConfigPath: Path = getPath(project.path, 'tsconfig.build.json');
await TsConfigUtilities.update(tsConfigPath, {
compilerOptions: { rootDir: undefined }
});

await NpmUtilities.updatePackageJson(
projectName,
{
Expand Down
4 changes: 3 additions & 1 deletion src/commands/add/add-ts-library/add-ts-library.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ export class AddTsLibraryCommand extends BaseAddCommand<TsLibraryConfiguration>
private async createProject(config: TsLibraryConfiguration): Promise<string> {
// eslint-disable-next-line no-console
console.log('Creates the library');
await CPUtilities.exec(`cd ${LIBS_DIRECTORY_NAME} && npm create vite@${this.VITE_VERSION} ${config.name} -- --template vanilla-ts`);
await CPUtilities.exec(
`cd ${LIBS_DIRECTORY_NAME} && npm create vite@${this.VITE_VERSION} ${config.name} --yes -- --template vanilla-ts`
);
const libraryPath: string = getPath(LIBS_DIRECTORY_NAME, config.name);
await FsUtilities.createFile(getPath(libraryPath, 'vite.config.ts'), [
'import { defineConfig, PluginOption } from \'vite\';',
Expand Down
2 changes: 1 addition & 1 deletion src/commands/down/down-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('DownCommand', () => {
const runningDockerServicesAfterDown: FullyParsedDockerService[] = await getDockerServices(false);

expect(runningDockerServicesAfterDown.length).toEqual(runningDockerServicesBeforeUp.length);
}, MAX_FAST_TIME * 2 /** We call up and down. */);
}, 1000 + (MAX_FAST_TIME * 2) /** We call up and down. */);

afterEach(() => {
jest.restoreAllMocks();
Expand Down
2 changes: 1 addition & 1 deletion src/commands/list/list-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('ListCommand', () => {

const command: DownCommand = new DownCommand();
await command.start(['d']);
}, MAX_FAST_TIME * 3 /** We call up, list and down. */);
}, 1000 + (MAX_FAST_TIME * 3) /** We call up, list and down. */);

afterEach(() => {
jest.restoreAllMocks();
Expand Down
2 changes: 1 addition & 1 deletion src/docker/docker-traefik.utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const TRAEFIK_COMPRESSION_LABEL: string = 'traefik.http.middlewares.compr
/**
* The traefik docker image, with version.
*/
export const TRAEFIK_DOCKER_IMAGE: string = 'traefik:v3.2';
export const TRAEFIK_DOCKER_IMAGE: string = 'traefik:v3.6';

/**
* The base traefik commands.
Expand Down
2 changes: 1 addition & 1 deletion src/docker/docker-utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('DockerUtilities', () => {
'services:',
'',
' traefik:',
' image: traefik:v3.2',
' image: traefik:v3.6',
' restart: unless-stopped',
' command:',
' - --providers.docker=true',
Expand Down
4 changes: 2 additions & 2 deletions src/encapsulation/cp.utilities.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { execSync, ExecSyncOptions } from 'child_process';

import { ChalkUtilities } from './chalk.utilities';
import { exitGracefully, exitWithInterrupt, isErrorWithSignal, isExitPromptError } from '../utilities';
import { exitWithInterrupt, isErrorWithSignal, isExitPromptError } from '../utilities';

/**
* Encapsulates functionality of the child_process package.
Expand Down Expand Up @@ -35,7 +35,7 @@ export abstract class CPUtilities {
}
// eslint-disable-next-line no-console
console.error(ChalkUtilities.error(`Command failed: ${command}`));
await exitGracefully(1);
throw error;
}
}
}
8 changes: 5 additions & 3 deletions src/loopback/loopback.utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { AddLoopbackConfiguration } from '../commands/add/add-loopback';
import { ENVIRONMENT_MODEL_TS_FILE_NAME } from '../constants';
import { CPUtilities, FsUtilities } from '../encapsulation';
import { DefaultEnvKeys, EnvUtilities, EnvValue } from '../env';
import { NpmPackage, NpmUtilities } from '../npm';
import { TsUtilities } from '../ts';
import { generatePlaceholderPassword, getPath, optionsToCliString, Path, toKebabCase, toPascalCase } from '../utilities';
import { LbDatabaseConfig } from './lb-database-config.model';
import { NpmPackage, NpmUtilities } from '../npm';
import { adminControllerContent } from './admin-controller.content';
import { adminModelContent } from './admin-model.content';
import { fullAdminModelContent } from './full-admin-model.content';
import { LbDatabaseConfig } from './lb-database-config.model';
import { newAdminModelContent } from './new-admin-model.content';

/**
Expand Down Expand Up @@ -172,7 +172,9 @@ export abstract class LoopbackUtilities {
// for the new command, extract the name
command = command.split(' ')[1] as LoopbackCliCommands;
}
await CPUtilities.exec(`cd ${directory} && npx @loopback/cli@${this.CLI_VERSION} ${command} ${optionsToCliString(options, ' ')}`);
await CPUtilities.exec(
`cd ${directory} && npx --yes @loopback/cli@${this.CLI_VERSION} ${command} ${optionsToCliString(options, ' ')}`
);
if (command.startsWith('service')) {
const servicePath: Path = getPath(directory, 'src', 'services', `${toKebabCase(command.split(' ')[1])}.service.ts`);
await FsUtilities.replaceInFile(servicePath, '/* inject, */', '');
Expand Down
4 changes: 3 additions & 1 deletion src/nest/nest-utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ describe('NestUtilities', () => {
await NestUtilities.runCommand(mockConstants.APPS_DIR, 'new api', {
'--language': 'TS',
'--package-manager': 'npm',
'--type': 'cjs',
'--skip-git': true,
'--skip-install': true
'--skip-install': true,
'--no-observe': true
});

const dirExists: boolean = await FsUtilities.exists(getPath(mockConstants.APPS_DIR, 'api'));
Expand Down
36 changes: 32 additions & 4 deletions src/nest/nest.utilities.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ModuleMetadata } from '@nestjs/common';
import type { ModuleMetadata } from '@nestjs/common';

import { CPUtilities, FsUtilities, JsonUtilities } from '../encapsulation';
import { TsUtilities } from '../ts';
Expand Down Expand Up @@ -28,14 +28,22 @@ type NewOptions = {
* Whether or not git initialization should be skipped.
*/
'--skip-git': true,
/**
* Don't add nestjs observe.
*/
'--no-observe': true,
/**
* The package manager to use.
*/
'--package-manager': 'npm',
/**
* The language to use.
*/
'--language': 'TS'
'--language': 'TS',
/**
* Whether to use common js or ecma script.
*/
'--type': 'cjs'
};

/**
Expand All @@ -50,7 +58,7 @@ type NestCliOptions<T extends NestCliCommands>
*/
export abstract class NestUtilities {

private static readonly CLI_VERSION: number = 11;
private static readonly CLI_VERSION: number = 12;

/**
* Runs an nest cli command inside the provided directory.
Expand All @@ -59,7 +67,27 @@ export abstract class NestUtilities {
* @param options - Options for running the command.
*/
static async runCommand(directory: Path, command: NestCliCommands, options: NestCliOptions<typeof command>): Promise<void> {
await CPUtilities.exec(`cd ${directory} && npx @nestjs/cli@${this.CLI_VERSION} ${command} ${optionsToCliString(options)}`);
if (command.startsWith('new ')) {
await this.runNewSchematic(directory, command);
return;
}
await CPUtilities.exec(`cd ${directory} && npx --yes @nestjs/cli@${this.CLI_VERSION} ${command} ${optionsToCliString(options)}`);
}

private static async runNewSchematic(directory: Path, command: CliNew): Promise<void> {
const name: string = command.slice('new '.length);

await CPUtilities.exec(
// eslint-disable-next-line stylistic/max-len
`cd ${directory} && npx --yes --package @nestjs/schematics@${this.CLI_VERSION} --package @angular-devkit/schematics-cli schematics @nestjs/schematics:application `
+ `--name=${name} `
+ '--strict '
+ '--package-manager=npm '
+ '--language=ts '
+ '--type=cjs '
+ '--skip-install '
+ '--skip-git'
);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/storybook/storybook.utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { Path } from '../utilities';
*/
export abstract class StorybookUtilities {

private static readonly CLI_VERSION: number = 9;
private static readonly CLI_VERSION: number = 10;

/**
* Sets up storybook inside the given root.
* @param root - The root of the project where storybook should be setup.
*/
static async setup(root: Path): Promise<void> {
await CPUtilities.exec(
`cd ${root} && npm create storybook@${this.CLI_VERSION} -- --no-dev --yes --features docs test --disable-telemetry`
`cd ${root} && npm create storybook@${this.CLI_VERSION} --yes -- --no-dev --yes --features docs test --disable-telemetry`
);
}
}
10 changes: 7 additions & 3 deletions src/tsconfig/tsconfig.utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export abstract class TsConfigUtilities {
* @param path - Where to initialize typescript.
*/
static async init(path: Path): Promise<void> {
await CPUtilities.exec(`cd ${path} && npx tsc --init`);
await CPUtilities.exec(`cd ${path} && npx --yes tsc --init`);
}

/**
Expand All @@ -26,7 +26,6 @@ export abstract class TsConfigUtilities {
compileOnSave: false,
compilerOptions: {
allowSyntheticDefaultImports: true,
baseUrl: '.',
declaration: false,
emitDecoratorMetadata: true,
experimentalDecorators: true,
Expand Down Expand Up @@ -72,7 +71,12 @@ export abstract class TsConfigUtilities {
await this.update(getPath(BASE_TS_CONFIG_FILE_NAME), data);
}

private static async update(path: Path, data: Partial<TsConfig>): Promise<void> {
/**
* Updates the tsconfig at the given path with the given data.
* @param path - The path of the tsconfig.
* @param data - The data to update the tsconfig with.
*/
static async update(path: Path, data: Partial<TsConfig>): Promise<void> {
const oldConfig: TsConfig = await FsUtilities.parseFileAs(path);
const tsconfig: TsConfig = mergeDeep<TsConfig>(oldConfig, data);
await FsUtilities.updateFile(path, JsonUtilities.stringify(tsconfig), 'replace', false);
Expand Down
13 changes: 2 additions & 11 deletions src/zibri/zibri.utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,7 @@ type ZibriCliCommands = CliNew;
/**
* Cli Options for running zi new.
*/
type NewOptions = never; {
// /**
// * Whether or not npm install should be skipped.
// */
// '--skip-install': true,
// /**
// * Whether or not git initialization should be skipped.
// */
// '--skip-git': true
}
type NewOptions = never;

/**
* Possible zibri cli options, narrowed down based on the provided command.
Expand All @@ -46,6 +37,6 @@ export abstract class ZibriUtilities {
* @param options - Options for running the command.
*/
static async runCommand(directory: Path, command: ZibriCliCommands, options: ZibriCliOptions<typeof command>): Promise<void> {
await CPUtilities.exec(`cd ${directory} && npx zibri-cli@${this.CLI_VERSION} ${command} ${optionsToCliString(options)}`);
await CPUtilities.exec(`cd ${directory} && npx --yes zibri-cli@${this.CLI_VERSION} ${command} ${optionsToCliString(options)}`);
}
}
Loading