Skip to content

Commit b35a418

Browse files
authored
Merge pull request #86 from Service-Soft/82-add-command-for-listing-all-monorepos-with-their-respective-docker-services
added ls and la commands
2 parents 71105bb + 99ca642 commit b35a418

33 files changed

Lines changed: 575 additions & 76 deletions

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ The projects that can be added to a Monux monorepo also provide a lot of functio
4040
- [Initializing a new monorepo](#initializing-a-new-monorepo)
4141
- [Adding a new project to the monorepo](#adding-a-new-project-to-the-monorepo)
4242
- [Running development services](#running-development-services)
43+
- [Listing monorepo services](#listing-monorepo-services)
4344
- [Running npm scripts](#running-npm-scripts)
4445
- [Running npm scripts in multiple projects](#running-npm-scripts-in-multiple-projects)
4546
- [Handling environment variables](#handling-environment-variables)
@@ -108,6 +109,11 @@ That section also includes a guide on how to add projects manually.
108109
Some things like databases will be added to the monorepo solely in the docker compose.<br>
109110
To use these during development, the cli includes the `mx up-dev` command.
110111

112+
## Listing monorepo services
113+
To list all of Monux monorepos and their respective docker services we included the `mx ls` and `mx la` commands.
114+
115+
Where `ls` or `list` only shows monorepos with currently running docker services, while `la` or `list-all` also shows monorepos with stopped docker services.
116+
111117
## Running npm scripts
112118
To run an npm script of one of your projects you can use `mx {projectName} {npmScript}`. This works for projects in the "apps" and "libs" directories of your monorepo.
113119

@@ -140,7 +146,7 @@ But instead of parsing the values from the `.env`-file during the prepare step,
140146
/**
141147
* Defines how the CalculatedGlobalEnvironment values should be calculated.
142148
* This is used by the "mx prepare" command.
143-
* DONT CHANGE THE NAME ("calculationSchemaFor") OR FORMATTING. Otherwise Monux might not be able to detect it.
149+
* DON'T CHANGE THE NAME ("calculationSchemaFor") OR FORMATTING. Otherwise Monux might not be able to detect it.
144150
*/
145151
const calculationSchemaFor: Record<
146152
keyof CalculatedGlobalEnvironment,

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { configs } from 'eslint-config-service-soft';
22

3+
// eslint-disable-next-line jsdoc/require-description
34
/** @type {import('eslint').Linter.Config} */
45
export default [
56
...configs,

jest.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
// eslint-disable-next-line jsdoc/require-description
13
/** @type {import('ts-jest').JestConfigWithTsJest} **/
24
const config = {
35
testEnvironment: 'node',

package-lock.json

Lines changed: 32 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "monux-cli",
3-
"version": "2.1.1",
3+
"version": "2.1.2",
44
"license": "MIT",
55
"main": "index.js",
66
"engines": {
@@ -40,6 +40,7 @@
4040
},
4141
"dependencies": {
4242
"chalk": "^4.1.2",
43+
"cli-table3": "^0.6.5",
4344
"death": "^1.1.0",
4445
"figlet": "^1.7.0",
4546
"inquirer": "^10.2.2",
@@ -54,7 +55,7 @@
5455
"@types/figlet": "^1.5.8",
5556
"@types/js-yaml": "^4.0.9",
5657
"eslint": "^9.24.0",
57-
"eslint-config-service-soft": "^2.0.0",
58+
"eslint-config-service-soft": "^2.0.8",
5859
"jest": "^29.7.0",
5960
"ngx-material-navigation": "^18.1.2",
6061
"ts-jest": "^29.2.5"

src/__testing__/mock/file-mock.utilities.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { MockConstants, FileMockConstants, DirMockConstants } from './constants'
33
import { AngularJson } from '../../angular';
44
import { CPUtilities, FsUtilities, JsonUtilities } from '../../encapsulation';
55
import { EnvUtilities } from '../../env';
6+
import { WorkspaceUtilities } from '../../workspace';
67

78
export abstract class FileMockUtilities {
89

@@ -38,6 +39,7 @@ export abstract class FileMockUtilities {
3839
CPUtilities['cwd'] = mockConstants.PROJECT_DIR;
3940
await this.mockFolders(mockConstants);
4041
await this.mockFiles(filesToMock, contentOverrides, mockConstants);
42+
await WorkspaceUtilities.createConfig();
4143
}
4244

4345
private static async mockFolders(mockConstants: MockConstants): Promise<void> {

src/angular/angular.utilities.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,10 +616,11 @@ export abstract class AngularUtilities {
616616
* Adds a sitemap.xml and a robots.txt to a project at the given path.
617617
* @param root - The root of the angular project to add the files to.
618618
* @param projectName - The name of the project.
619+
* @param domain - The domain of the project. Is needed to create the robots.txt file when the baseUrl environment variable has not been set yet.
619620
*/
620-
static async addSitemapAndRobots(root: string, projectName: string): Promise<void> {
621+
static async addSitemapAndRobots(root: string, projectName: string, domain: string): Promise<void> {
621622
const app: WorkspaceProject = await WorkspaceUtilities.findProjectOrFail(projectName);
622-
await RobotsUtilities.createRobotsTxtForApp(app, 'dev.docker-compose.yaml');
623+
await RobotsUtilities.createRobotsTxtForApp(app, 'dev.docker-compose.yaml', domain);
623624
await FsUtilities.createFile(getPath(root, 'src', SITEMAP_FILE_NAME), [
624625
'<?xml version="1.0" encoding="UTF-8"?>',
625626
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">',

src/commands/add/add-angular-website/add-angular-website.command.ts

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -79,35 +79,33 @@ export class AddAngularWebsiteCommand extends AddCommand<AddAngularWebsiteConfig
7979
);
8080
const domain: string = config.subDomain ? `${config.subDomain}.${prodRootDomain}` : prodRootDomain;
8181

82-
await AngularUtilities.addSitemapAndRobots(root, config.name);
82+
await AngularUtilities.addSitemapAndRobots(root, config.name, domain);
8383

84-
await Promise.all([
85-
this.cleanUp(root),
86-
this.setupTsConfig(root, config.name),
87-
this.createDockerfile(root, config),
88-
AngularUtilities.setupNavigation(root, config.name),
89-
EslintUtilities.setupProjectEslint(root, true),
90-
this.setupTailwind(root),
91-
DockerUtilities.addServiceToCompose(
92-
{
93-
name: config.name,
94-
build: {
95-
dockerfile: `./${root}/${DOCKER_FILE_NAME}`,
96-
context: '.'
97-
},
98-
volumes: [{ path: `/${config.name}` }]
84+
await this.cleanUp(root);
85+
await this.setupTsConfig(root, config.name);
86+
await this.createDockerfile(root, config);
87+
await AngularUtilities.setupNavigation(root, config.name);
88+
await EslintUtilities.setupProjectEslint(root, true);
89+
await this.setupTailwind(root);
90+
await DockerUtilities.addServiceToCompose(
91+
{
92+
name: config.name,
93+
build: {
94+
dockerfile: `./${root}/${DOCKER_FILE_NAME}`,
95+
context: '.'
9996
},
100-
4000,
101-
true,
102-
config.subDomain
103-
),
104-
AngularUtilities.updateAngularJson(
105-
getPath(root, ANGULAR_JSON_FILE_NAME),
106-
{ $schema: '../../node_modules/@angular/cli/lib/config/schema.json' }
107-
),
108-
AngularUtilities.setupMaterial(root),
109-
EnvUtilities.setupProjectEnvironment(root, false)
110-
]);
97+
volumes: [{ path: `/${config.name}` }]
98+
},
99+
4000,
100+
true,
101+
config.subDomain
102+
);
103+
await AngularUtilities.updateAngularJson(
104+
getPath(root, ANGULAR_JSON_FILE_NAME),
105+
{ $schema: '../../node_modules/@angular/cli/lib/config/schema.json' }
106+
);
107+
await AngularUtilities.setupMaterial(root);
108+
await EnvUtilities.setupProjectEnvironment(root, false);
111109
await this.createDefaultPages(root, config.titleSuffix, domain);
112110
if (config.addTracking) {
113111
await AngularUtilities.setupTracking(config.name);

src/commands/command.enum.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,9 @@ export enum Command {
2828
GP = 'gp',
2929
RUN_ALL = 'run-all',
3030
RUN_MANY = 'run-many',
31-
RA = 'ra'
31+
RA = 'ra',
32+
LIST = 'list',
33+
LS = 'ls',
34+
LIST_ALL = 'list-all',
35+
LA = 'la'
3236
}

src/commands/down-dev/down-dev.command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ import { CPUtilities } from '../../encapsulation';
55
* Shuts down the dev services.
66
*/
77
export function runDownDev(): void {
8-
CPUtilities.execSync(`docker compose -f ${DEV_DOCKER_COMPOSE_FILE_NAME} down`);
8+
CPUtilities.execSync(`docker compose -f ${DEV_DOCKER_COMPOSE_FILE_NAME} stop`);
99
}

0 commit comments

Comments
 (0)