libmodulor 0.6.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v0.8.0 (2025-03-13)
4
+
5
+ **BREAKING**
6
+
7
+ - Move `NodeExpressServerManager` to a dedicated export (`libmodulor/node` => `libmodulor/node-express`). The following dependencies (`cookie-parser`, `express`, `express-fileupload` and `helmet`) are now optional. You can remove them if you're using `libmodulor/node` elements in non server targets like `cli`
8
+ - Do not enforce `dt` and `policies` folders in app src : place everything that **is not** `*UCD` and `*ServerMain` into `lib` the way you prefer
9
+ - Check app src folder contents : it must contain only the elements allowed by the spec (Re-generate your tests `yarn libmodulor GenerateAppsTests` to enforce the new rule)
10
+
11
+ **Misc**
12
+
13
+ - Introduce new "Basic" example showing all the primitives in action in one single `.ts` file
14
+ - Move `examples/libmodulor-tuto` to `examples/supertrader`
15
+ - Add `llms.txt` to docs at https://libmodulor.c100k.eu/llms.txt
16
+
17
+ ## v0.7.0 (2025-03-07)
18
+
19
+ **Added**
20
+
21
+ - Make `npx libmodulor CreateProject` more generic : you can now customize the `initialCommit` (default is `chore: initial commit`), the `pkgManagerBin` (default is `yarn`, works with `npm`, `pnpm`, `bun`, etc.), the `scmBin` (default is `git`)
22
+
23
+ **Fixed**
24
+
25
+ - Derandomize UC input before snapshotting in tests : after the upgrade to TS 5.8, snapshotting a UC including a File as input would break as a new `state` property has appeared with a dynamic `lastModified` property
26
+
27
+ **Misc**
28
+
29
+ - Move the documentation with concepts, examples, guides and references to https://libmodulor.c100k.eu
30
+
3
31
  ## v0.6.1 (2025-02-28)
4
32
 
5
33
  **Fixed**
package/README.md CHANGED
@@ -5,39 +5,17 @@
5
5
 
6
6
  An opinionated TypeScript library to create business oriented applications.
7
7
 
8
- Applications created with `libmodulor` have **6 main properties** :
9
-
10
- - Strictly typed with explicit business data types
11
- - Fully typed e2e without code generation
12
- - Auto documented
13
- - Auto tested
14
- - Multi platforms/runtimes
15
- - Runnable anywhere
16
-
17
8
  > [!WARNING]
18
9
  > The project is still in active development. Although already used in pilot projects, it's not suitable for all production scenarios yet.
19
10
  > Being developed by only one person, it may keep going for years or stop at any time.
20
11
  > In the meantime, it's still a "research project" that needs improvement. Thus, it will be subject to BREAKING CHANGES as long as the version is not `1.0.0`.
21
- > All that said, the end goal is really to have a **production-grade library** to help everyone build **quality projects faster**. If you want to help in any way or have questions, feel free to contact me (cf. `author` in `package.json`).
22
-
23
- > [!NOTE]
24
- > At the beginning, the whole documentation will be on GitHub, starting from this file, to make it easier to have the big picture, maintain and <kbd>cmd</kbd> + <kbd>F</kbd>. At some point, I'll consider having a beautiful documentation website like all the cool kids.
25
-
26
- ---
12
+ > All that said, the end goal is really to have a **production-grade library** to help everyone build **quality projects faster**.
27
13
 
28
14
  ## 🚀 Getting Started
29
15
 
30
- If you're discovering `libmodulor`, we recommend reading the [📖 Introduction](https://github.com/c100k/libmodulor/blob/v0.6.1/docs/Introduction.md) first. It will give you an overview of what `libmodulor` is and how it works.
31
-
32
- If you want to learn by doing, you can follow the [🚀 Tutorial](https://github.com/c100k/libmodulor/blob/v0.6.1/docs/Tutorial.md). It contains multiple steps showing you the basics of `libmodulor`. We'll build a small Trading app that will allow us to buy an asset from `curl`, a SPA, a CLI, Claude Desktop, an Android mobile app and an iOS mobile app !
33
-
34
- If you're felling adventurous, create a project and start building your own application, with your own apps, use cases, products, targets :
35
-
36
- ```sh
37
- npx libmodulor CreateProject --outPath ~/Downloads --projectName libmodulor-projx
38
- ```
16
+ If you're discovering `libmodulor`, we recommend reading the [📖 Documentation](https://libmodulor.c100k.eu/docs) first. You'll find everything you need to get started : Concepts, Examples and Guides.
39
17
 
40
- Finally, for more advanced uses, check out the [📜 Guides](https://github.com/c100k/libmodulor/blob/v0.6.1/docs/Guides.md).
18
+ When you're ready, [🚀 Create a project](https://libmodulor.c100k.eu/docs/guides/create-project) and build the awesome idea you have in mind.
41
19
 
42
20
  ## 👨‍💻 Contribute
43
21
 
@@ -45,4 +23,4 @@ If you think you can help in any way, feel free to contact me (cf. `author` in `
45
23
 
46
24
  ## ⚖️ License
47
25
 
48
- [LGPL-3.0](https://github.com/c100k/libmodulor/blob/v0.6.1/LICENSE)
26
+ [LGPL-3.0](https://github.com/c100k/libmodulor/blob/v0.8.0/LICENSE)
@@ -11,10 +11,13 @@ export const I18n = {
11
11
  uc_TestApp_label: 'Test app',
12
12
  ucif_appPath_desc: 'The path of the app',
13
13
  ucif_appsPath_desc: 'The path to the directory containing all the apps',
14
- ucif_projectName_desc: "Name of the project conforming to the package.json's spec (i.e. a-z, 0-9, -)",
15
- ucif_outPath_desc: 'Path to a directory where to create the project. Do not include the project name in it. It is created recursively if missing.',
16
- ucif_monkeyTestingTimeoutInMs_desc: 'These tests can take longer than the usual default of 5000ms because they try lots of possibilities',
17
14
  ucif_depsMapping_desc: 'The mapping of dependencies in case some of them need a specific pattern (e.g. one directory above the default)',
15
+ ucif_initialCommit_desc: 'The message of the initial commit',
16
+ ucif_monkeyTestingTimeoutInMs_desc: 'These tests can take longer than the usual default of 5000ms because they try lots of possibilities',
17
+ ucif_outPath_desc: 'Path to a directory where to create the project. Do not include the project name in it. It is created recursively if missing.',
18
+ ucif_pkgManagerBin_desc: "The package manager to use to install the deps and run the dev commands (must conform to npm's API)",
19
+ ucif_projectName_desc: "Name of the project conforming to the package.json's spec (i.e. a-z, 0-9, -)",
20
+ ucif_scmBin_desc: "The source control manager to use to init and commit (must conform to git's API)",
18
21
  ucif_serverPortRangeStart_desc: 'The port number to start with when generating the server to test (incremented by 1) for each app',
19
22
  ucif_skipCoverage_desc: 'Whether to skip coverage or not',
20
23
  ucif_updateSnapshots_desc: "Whether to update the snapshots or not. Typically, update them if the tests fail because the snapshots don't match, the reason being that you changed the implementation",
@@ -1,2 +1,3 @@
1
1
  import type { FileName, Slug } from '../../../../dt/index.js';
2
+ export declare const PACKAGE_JSON: (name: Slug) => string;
2
3
  export declare function projectFiles(name: Slug): Map<FileName, string>;
@@ -26,7 +26,7 @@ const BIOME_JSON = `{
26
26
  }
27
27
  }
28
28
  `;
29
- const PACKAGE_JSON = (name) => `{
29
+ export const PACKAGE_JSON = (name) => `{
30
30
  "name": "${name}",
31
31
  "version": "0.1.0",
32
32
  "type": "module",
@@ -42,8 +42,8 @@ const PACKAGE_JSON = (name) => `{
42
42
  },
43
43
  "devDependencies": {
44
44
  "@biomejs/biome": "^1.9.4",
45
- "@types/node": "^22.13.5",
46
- "@vitest/coverage-v8": "^3.0.7",
45
+ "@types/node": "^22.13.10",
46
+ "@vitest/coverage-v8": "^3.0.8",
47
47
  "buffer": "^6.0.3",
48
48
  "cookie-parser": "^1.4.7",
49
49
  "express": "^4.21.2",
@@ -51,9 +51,9 @@ const PACKAGE_JSON = (name) => `{
51
51
  "fast-check": "^3.23.2",
52
52
  "helmet": "^8.0.0",
53
53
  "jose": "^6.0.8",
54
- "typescript": "^5.7.3",
55
- "vite": "^6.2.0",
56
- "vitest": "^3.0.7"
54
+ "typescript": "^5.8.2",
55
+ "vite": "^6.2.1",
56
+ "vitest": "^3.0.8"
57
57
  }
58
58
  }
59
59
  `;
@@ -1,9 +1,12 @@
1
- import { type DirPath, type Slug } from '../../../../dt/index.js';
1
+ import { type DirPath, type FileName, type FreeTextShort, type Slug } from '../../../../dt/index.js';
2
2
  import type { FSManager, Logger, ShellCommandExecutor } from '../../../../std/index.js';
3
3
  import { type UCDef, type UCInput, type UCInputFieldValue, type UCMain, type UCMainInput } from '../../../../uc/index.js';
4
4
  export interface CreateProjectInput extends UCInput {
5
+ initialCommit: UCInputFieldValue<FreeTextShort>;
5
6
  outPath: UCInputFieldValue<DirPath>;
7
+ pkgManagerBin: UCInputFieldValue<FileName>;
6
8
  projectName: UCInputFieldValue<Slug>;
9
+ scmBin: UCInputFieldValue<FileName>;
7
10
  }
8
11
  export declare class CreateProjectClientMain implements UCMain<CreateProjectInput> {
9
12
  private fsManager;
@@ -11,5 +14,13 @@ export declare class CreateProjectClientMain implements UCMain<CreateProjectInpu
11
14
  private shellCommandExecutor;
12
15
  constructor(fsManager: FSManager, logger: Logger, shellCommandExecutor: ShellCommandExecutor);
13
16
  exec({ uc }: UCMainInput<CreateProjectInput>): Promise<void>;
17
+ private assertBinPresence;
18
+ private commit;
19
+ private createConfigFiles;
20
+ private createDirs;
21
+ private createRootDir;
22
+ private initRepository;
23
+ private installDeps;
24
+ private runDevCmds;
14
25
  }
15
26
  export declare const CreateProjectUCD: UCDef<CreateProjectInput>;
@@ -12,7 +12,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  };
13
13
  import { inject, injectable } from 'inversify';
14
14
  import { APPS_ROOT_PATH, PRODUCTS_ROOT_PATH } from '../../../../convention.js';
15
- import { TDirPath, TSlug, } from '../../../../dt/index.js';
15
+ import { TDirPath, TFileName, TFreeTextShort, TSlug, } from '../../../../dt/index.js';
16
+ import { IllegalArgumentError } from '../../../../error/index.js';
16
17
  import { EverybodyUCPolicy, } from '../../../../uc/index.js';
17
18
  import { projectFiles } from '../lib/project.js';
18
19
  import { Manifest } from '../manifest.js';
@@ -26,55 +27,95 @@ let CreateProjectClientMain = class CreateProjectClientMain {
26
27
  this.shellCommandExecutor = shellCommandExecutor;
27
28
  }
28
29
  async exec({ uc }) {
30
+ const initialCommit = uc.reqVal0('initialCommit');
29
31
  const outPath = uc.reqVal0('outPath');
32
+ const pkgManagerBin = uc.reqVal0('pkgManagerBin');
30
33
  const projectName = uc.reqVal0('projectName');
34
+ const scmBin = uc.reqVal0('scmBin');
35
+ await this.assertBinPresence(pkgManagerBin);
36
+ await this.assertBinPresence(scmBin);
31
37
  const cwd = this.fsManager.path(outPath, projectName);
32
- this.logger.info('Creating root dir : %s', cwd);
33
- await this.fsManager.mkdir(cwd, { recursive: true });
34
- this.logger.info('Initializing git repository');
35
- await this.shellCommandExecutor.exec({
36
- bin: 'git',
37
- opts: { args: ['init'], cwd },
38
- });
39
- this.logger.info('Creating config files');
38
+ // TODO : Rollback the whole thing in case of failure
39
+ await this.createRootDir(cwd);
40
+ await this.initRepository(scmBin, cwd);
41
+ await this.createConfigFiles(projectName, cwd);
42
+ await this.createDirs(cwd);
43
+ await this.installDeps(pkgManagerBin, cwd);
44
+ await this.commit(scmBin, initialCommit, cwd);
45
+ await this.runDevCmds(pkgManagerBin, cwd);
46
+ this.logger.info('Done ! Project ready ! ✅ 🚀');
47
+ }
48
+ async assertBinPresence(bin) {
49
+ try {
50
+ await this.shellCommandExecutor.exec({
51
+ bin: bin,
52
+ opts: { args: ['--version'] },
53
+ });
54
+ }
55
+ catch (err) {
56
+ throw new IllegalArgumentError(`'${bin}' seems missing. Is it installed on your machine ?`);
57
+ }
58
+ }
59
+ async commit(scmBin, initialCommit, cwd) {
60
+ this.logger.info('Committing');
61
+ const cmdArgs = [
62
+ ['branch', '-M', 'master'],
63
+ ['add', '.'],
64
+ ['commit', '-am', initialCommit],
65
+ ];
66
+ for await (const args of cmdArgs) {
67
+ await this.shellCommandExecutor.exec({
68
+ bin: scmBin,
69
+ opts: { args, cwd },
70
+ });
71
+ }
72
+ }
73
+ async createConfigFiles(projectName, cwd) {
40
74
  const files = projectFiles(projectName);
41
75
  for await (const [fileName, content] of files) {
42
76
  const path = this.fsManager.path(cwd, fileName);
43
77
  await this.fsManager.touch(path, content);
44
78
  }
45
- const dirs = [APPS_ROOT_PATH, PRODUCTS_ROOT_PATH];
79
+ }
80
+ async createDirs(cwd) {
46
81
  this.logger.info('Creating apps and products directories');
82
+ const dirs = [APPS_ROOT_PATH, PRODUCTS_ROOT_PATH];
47
83
  for await (const dirPath of dirs) {
48
84
  const path = this.fsManager.path(cwd, ...dirPath);
49
85
  await this.fsManager.mkdir(path, { recursive: true });
50
86
  await this.fsManager.touch(this.fsManager.path(path, '.gitkeep'), '');
51
87
  }
52
- this.logger.info('Installing dependencies');
88
+ }
89
+ async createRootDir(cwd) {
90
+ this.logger.info('Creating root dir : %s', cwd);
91
+ await this.fsManager.mkdir(cwd, { recursive: true });
92
+ }
93
+ async initRepository(scmBin, cwd) {
94
+ const cmd = 'init';
95
+ this.logger.info('Initializing repository : %s %s', scmBin, cmd);
53
96
  await this.shellCommandExecutor.exec({
54
- bin: 'yarn',
55
- opts: { args: ['install'], cwd },
97
+ bin: scmBin,
98
+ opts: { args: [cmd], cwd },
56
99
  });
57
- this.logger.info('Committing');
58
- const cmdArgs = [
59
- ['branch', '-M', 'master'],
60
- ['add', '.'],
61
- ['commit', '-am', '"chore: initial commit"'],
62
- ];
63
- for await (const args of cmdArgs) {
64
- await this.shellCommandExecutor.exec({
65
- bin: 'git',
66
- opts: { args, cwd },
67
- });
68
- }
69
- const devCmds = ['lint', 'test'];
70
- for await (const cmd of devCmds) {
71
- this.logger.info('Testing dev command : yarn %s', cmd);
100
+ }
101
+ async installDeps(pkgManagerBin, cwd) {
102
+ const cmd = 'install';
103
+ this.logger.info('Installing dependencies : %s %s', pkgManagerBin, cmd);
104
+ await this.shellCommandExecutor.exec({
105
+ bin: pkgManagerBin,
106
+ opts: { args: [cmd], cwd },
107
+ });
108
+ }
109
+ async runDevCmds(pkgManagerBin, cwd) {
110
+ const cmd = 'run';
111
+ const scripts = ['lint', 'test'];
112
+ for await (const script of scripts) {
113
+ this.logger.info('Running dev command : %s %s %s', pkgManagerBin, cmd, script);
72
114
  await this.shellCommandExecutor.exec({
73
- bin: 'yarn',
74
- opts: { args: [cmd], cwd },
115
+ bin: pkgManagerBin,
116
+ opts: { args: [cmd, script], cwd },
75
117
  });
76
118
  }
77
- this.logger.info('Done ! Project ready ! ✅ 🚀');
78
119
  }
79
120
  };
80
121
  CreateProjectClientMain = __decorate([
@@ -94,6 +135,14 @@ export const CreateProjectUCD = {
94
135
  io: {
95
136
  i: {
96
137
  fields: {
138
+ initialCommit: {
139
+ cardinality: {
140
+ min: 0,
141
+ },
142
+ type: new TFreeTextShort()
143
+ .setDefaultValue('chore: initial commit')
144
+ .setExamples(['chore: initial commit']),
145
+ },
97
146
  outPath: {
98
147
  cardinality: {
99
148
  min: 0,
@@ -102,9 +151,25 @@ export const CreateProjectUCD = {
102
151
  .setDefaultValue('./')
103
152
  .setExamples([['~', 'Desktop'].join('/')]),
104
153
  },
154
+ pkgManagerBin: {
155
+ cardinality: {
156
+ min: 0,
157
+ },
158
+ type: new TFileName()
159
+ .setDefaultValue('yarn')
160
+ .setExamples(['bun', 'npm', 'pnpm', 'yarn']),
161
+ },
105
162
  projectName: {
106
163
  type: new TSlug(),
107
164
  },
165
+ scmBin: {
166
+ cardinality: {
167
+ min: 0,
168
+ },
169
+ type: new TFileName()
170
+ .setDefaultValue('git')
171
+ .setExamples(['git']),
172
+ },
108
173
  },
109
174
  },
110
175
  },
@@ -10,12 +10,15 @@ export declare const APP_I18N_FILE_NAME: string;
10
10
  export declare const APP_INDEX_NAME: string;
11
11
  export declare const APP_INDEX_FILE_NAME: string;
12
12
  export declare const APP_INDEX_FILE_NAME_FOR_IMPORT: string;
13
+ export declare const APP_INSTALLER_FILE_NAME: string;
13
14
  export declare const APP_MANIFEST_NAME: string;
14
15
  export declare const APP_MANIFEST_FILE_EXT: string;
15
16
  export declare const APP_MANIFEST_FILE_NAME: string;
16
17
  export declare const APP_NAME_PLACEHOLDER: AppName;
17
18
  export declare const APP_ROOT_FROM_UCD: string[];
19
+ export declare const APP_SETTINGS_FILE_NAME: string;
18
20
  export declare const APP_SRC_DIR_NAME: string;
21
+ export declare const APP_SRC_LIB_DIR_NAME: string;
19
22
  export declare const APP_SRC_UCDS_DIR_NAME: string;
20
23
  export declare const APP_TEST_DIR_NAME: string;
21
24
  export declare const APP_TEST_MAIN_FILE_NAME: string;
@@ -14,12 +14,15 @@ export const APP_I18N_FILE_NAME = `${APP_I18N_NAME.toLowerCase()}.ts`;
14
14
  export const APP_INDEX_NAME = 'index';
15
15
  export const APP_INDEX_FILE_NAME = `${APP_INDEX_NAME}.ts`;
16
16
  export const APP_INDEX_FILE_NAME_FOR_IMPORT = 'index.js'; // ESM
17
+ export const APP_INSTALLER_FILE_NAME = 'installer.ts';
17
18
  export const APP_MANIFEST_NAME = 'Manifest';
18
19
  export const APP_MANIFEST_FILE_EXT = '.ts';
19
20
  export const APP_MANIFEST_FILE_NAME = `${APP_MANIFEST_NAME.toLowerCase()}${APP_MANIFEST_FILE_EXT}`;
20
21
  export const APP_NAME_PLACEHOLDER = 'AppX';
21
22
  export const APP_ROOT_FROM_UCD = ['..', '..', '..']; // $root/src/ucds/XyzUCD.ts
23
+ export const APP_SETTINGS_FILE_NAME = 'settings.ts';
22
24
  export const APP_SRC_DIR_NAME = SRC_DIR_NAME;
25
+ export const APP_SRC_LIB_DIR_NAME = 'lib';
23
26
  export const APP_SRC_UCDS_DIR_NAME = 'ucds';
24
27
  export const APP_TEST_DIR_NAME = 'test';
25
28
  export const APP_TEST_MAIN_FILE_NAME = 'App.test.ts';
@@ -0,0 +1 @@
1
+ export { NodeExpressServerManager } from './target/node-express-server/NodeExpressServerManager.js';
@@ -0,0 +1 @@
1
+ export { NodeExpressServerManager } from './target/node-express-server/NodeExpressServerManager.js';
@@ -8,7 +8,6 @@ export { NodeHTTPAPICallExecutorAgentBuilder } from './std/impl/NodeHTTPAPICallE
8
8
  export { NodePromptManager } from './std/impl/NodePromptManager.js';
9
9
  export { NodeSpawnShellCommandExecutor } from './std/impl/NodeSpawnShellCommandExecutor.js';
10
10
  export { NodeCoreCLIManager } from './target/node-core-cli/NodeCoreCLIManager.js';
11
- export { NodeExpressServerManager } from './target/node-express-server/NodeExpressServerManager.js';
12
11
  export { bindNodeCLI } from './utils/ioc/bindNodeCLI.js';
13
12
  export { bindNodeCore } from './utils/ioc/bindNodeCore.js';
14
13
  export { bindServer } from './utils/ioc/bindServer.js';
@@ -8,7 +8,6 @@ export { NodeHTTPAPICallExecutorAgentBuilder } from './std/impl/NodeHTTPAPICallE
8
8
  export { NodePromptManager } from './std/impl/NodePromptManager.js';
9
9
  export { NodeSpawnShellCommandExecutor } from './std/impl/NodeSpawnShellCommandExecutor.js';
10
10
  export { NodeCoreCLIManager } from './target/node-core-cli/NodeCoreCLIManager.js';
11
- export { NodeExpressServerManager } from './target/node-express-server/NodeExpressServerManager.js';
12
11
  export { bindNodeCLI } from './utils/ioc/bindNodeCLI.js';
13
12
  export { bindNodeCore } from './utils/ioc/bindNodeCore.js';
14
13
  export { bindServer } from './utils/ioc/bindServer.js';
@@ -1 +1 @@
1
- export { StripUCDLifecycleServerPlugin } from './bundlers/vite/StripUCDLifecycleServerPlugin.js';
1
+ export { StripUCDLifecycleServerPlugin } from './utils/bundling/vite/StripUCDLifecycleServerPlugin.js';
@@ -1 +1 @@
1
- export { StripUCDLifecycleServerPlugin } from './bundlers/vite/StripUCDLifecycleServerPlugin.js';
1
+ export { StripUCDLifecycleServerPlugin } from './utils/bundling/vite/StripUCDLifecycleServerPlugin.js';
@@ -21,7 +21,7 @@ let NodeSpawnShellCommandExecutor = class NodeSpawnShellCommandExecutor {
21
21
  proc.stdout.on('data', (chunk) => {
22
22
  stdout += chunk;
23
23
  });
24
- proc.stdout.on('error', (err) => {
24
+ proc.on('error', (err) => {
25
25
  reject(err);
26
26
  });
27
27
  proc.on('close', (code, signal) => {
@@ -12,6 +12,7 @@ import type { AppDocsEmitter } from './workers/AppDocsEmitter.js';
12
12
  import type { AppTestSuiteTestResult } from './workers/AppTestSuiteEmitter.js';
13
13
  import { AppTesterCtxInitializer } from './workers/AppTesterCtxInitializer.js';
14
14
  import { UCExecutor, type UCExecutorExecOutput, type Input as UCExecutorInput } from './workers/UCExecutor.js';
15
+ import { AppFolderChecker } from './workers/checkers/AppFolderChecker.js';
15
16
  import { AppI18nChecker } from './workers/checkers/AppI18nChecker.js';
16
17
  import { AppIndexChecker } from './workers/checkers/AppIndexChecker.js';
17
18
  import { AppManifestChecker } from './workers/checkers/AppManifestChecker.js';
@@ -31,6 +32,7 @@ export interface AppTesterUCTestData<I extends UCInput | undefined = undefined,
31
32
  }
32
33
  export declare class AppTester {
33
34
  private appDocsEmitter;
35
+ private appFolderChecker;
34
36
  private appI18nChecker;
35
37
  private appIndexChecker;
36
38
  private appManifestChecker;
@@ -51,7 +53,8 @@ export declare class AppTester {
51
53
  private testResults;
52
54
  private testSummary;
53
55
  private ucDefSourcesCheckerOutput;
54
- constructor(appDocsEmitter: AppDocsEmitter, appI18nChecker: AppI18nChecker, appIndexChecker: AppIndexChecker, appManifestChecker: AppManifestChecker, appTesterCtxInitializer: AppTesterCtxInitializer, serverManager: ServerManager, simpleHTMLAppTestReportEmitter: SimpleHTMLAppTestReportEmitter, ucBuilder: UCBuilder, ucDefChecker: UCDefChecker, ucDefSourcesChecker: UCDefSourcesChecker, ucExecutor: UCExecutor);
56
+ constructor(appDocsEmitter: AppDocsEmitter, appFolderChecker: AppFolderChecker, appI18nChecker: AppI18nChecker, appIndexChecker: AppIndexChecker, appManifestChecker: AppManifestChecker, appTesterCtxInitializer: AppTesterCtxInitializer, serverManager: ServerManager, simpleHTMLAppTestReportEmitter: SimpleHTMLAppTestReportEmitter, ucBuilder: UCBuilder, ucDefChecker: UCDefChecker, ucDefSourcesChecker: UCDefSourcesChecker, ucExecutor: UCExecutor);
57
+ checkAppFolder(): Promise<void>;
55
58
  checkAppI18n(): Promise<void>;
56
59
  checkAppIndex(): Promise<void>;
57
60
  checkAppManifest(): Promise<void>;
@@ -23,6 +23,7 @@ import { allWithExamples, defaultUCInputFillers, } from './uc-input.js';
23
23
  import { awaitForSrcImport } from './utils.js';
24
24
  import { AppTesterCtxInitializer } from './workers/AppTesterCtxInitializer.js';
25
25
  import { UCExecutor, } from './workers/UCExecutor.js';
26
+ import { AppFolderChecker } from './workers/checkers/AppFolderChecker.js';
26
27
  import { AppI18nChecker } from './workers/checkers/AppI18nChecker.js';
27
28
  import { AppIndexChecker } from './workers/checkers/AppIndexChecker.js';
28
29
  import { AppManifestChecker } from './workers/checkers/AppManifestChecker.js';
@@ -30,6 +31,7 @@ import { UCDefChecker } from './workers/checkers/UCDefChecker.js';
30
31
  import { UCDefSourcesChecker, } from './workers/checkers/UCDefSourcesChecker.js';
31
32
  let AppTester = class AppTester {
32
33
  appDocsEmitter;
34
+ appFolderChecker;
33
35
  appI18nChecker;
34
36
  appIndexChecker;
35
37
  appManifestChecker;
@@ -51,8 +53,9 @@ let AppTester = class AppTester {
51
53
  testResults;
52
54
  testSummary;
53
55
  ucDefSourcesCheckerOutput;
54
- constructor(appDocsEmitter, appI18nChecker, appIndexChecker, appManifestChecker, appTesterCtxInitializer, serverManager, simpleHTMLAppTestReportEmitter, ucBuilder, ucDefChecker, ucDefSourcesChecker, ucExecutor) {
56
+ constructor(appDocsEmitter, appFolderChecker, appI18nChecker, appIndexChecker, appManifestChecker, appTesterCtxInitializer, serverManager, simpleHTMLAppTestReportEmitter, ucBuilder, ucDefChecker, ucDefSourcesChecker, ucExecutor) {
55
57
  this.appDocsEmitter = appDocsEmitter;
58
+ this.appFolderChecker = appFolderChecker;
56
59
  this.appI18nChecker = appI18nChecker;
57
60
  this.appIndexChecker = appIndexChecker;
58
61
  this.appManifestChecker = appManifestChecker;
@@ -72,6 +75,14 @@ let AppTester = class AppTester {
72
75
  },
73
76
  };
74
77
  }
78
+ async checkAppFolder() {
79
+ const { errors } = await this.appFolderChecker.exec({
80
+ appPath: this.ctx.appPath,
81
+ });
82
+ if (errors.length > 0) {
83
+ throw new Error(errors[0]);
84
+ }
85
+ }
75
86
  async checkAppI18n() {
76
87
  const { errors } = await this.appI18nChecker.exec({
77
88
  appManifest: this.ctx.appManifest,
@@ -337,17 +348,19 @@ let AppTester = class AppTester {
337
348
  AppTester = __decorate([
338
349
  injectable(),
339
350
  __param(0, inject('AppDocsEmitter')),
340
- __param(1, inject(AppI18nChecker)),
341
- __param(2, inject(AppIndexChecker)),
342
- __param(3, inject(AppManifestChecker)),
343
- __param(4, inject(AppTesterCtxInitializer)),
344
- __param(5, inject('ServerManager')),
345
- __param(6, inject(SimpleHTMLAppTestReportEmitter)),
346
- __param(7, inject(UCBuilder)),
347
- __param(8, inject(UCDefChecker)),
348
- __param(9, inject(UCDefSourcesChecker)),
349
- __param(10, inject(UCExecutor)),
350
- __metadata("design:paramtypes", [Object, AppI18nChecker,
351
+ __param(1, inject(AppFolderChecker)),
352
+ __param(2, inject(AppI18nChecker)),
353
+ __param(3, inject(AppIndexChecker)),
354
+ __param(4, inject(AppManifestChecker)),
355
+ __param(5, inject(AppTesterCtxInitializer)),
356
+ __param(6, inject('ServerManager')),
357
+ __param(7, inject(SimpleHTMLAppTestReportEmitter)),
358
+ __param(8, inject(UCBuilder)),
359
+ __param(9, inject(UCDefChecker)),
360
+ __param(10, inject(UCDefSourcesChecker)),
361
+ __param(11, inject(UCExecutor)),
362
+ __metadata("design:paramtypes", [Object, AppFolderChecker,
363
+ AppI18nChecker,
351
364
  AppIndexChecker,
352
365
  AppManifestChecker,
353
366
  AppTesterCtxInitializer, Object, SimpleHTMLAppTestReportEmitter,
@@ -92,6 +92,10 @@ test('Sources should be valid', async () => {
92
92
  await runner.checkUCDSources();
93
93
  });
94
94
 
95
+ test('Folder should be valid', async () => {
96
+ await runner.checkAppFolder();
97
+ });
98
+
95
99
  test('${APP_MANIFEST_NAME} should be valid', async () => {
96
100
  await runner.checkAppManifest();
97
101
  });
@@ -42,4 +42,6 @@ export declare class UCExecutor implements Worker<Input, Promise<Output>> {
42
42
  exec<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>({ appManifest, auth, authName, inputFiller, inputFillerName, ucd, }: Input<I, OPI0, OPI1>): Promise<Output<I, OPI0, OPI1>>;
43
43
  overrideUCManager(ucManager: UCManager): void;
44
44
  private execClient;
45
+ private derandomizeInput;
46
+ private derandomizeInputFile;
45
47
  }
@@ -83,6 +83,36 @@ let UCExecutor = class UCExecutor {
83
83
  catch (err) {
84
84
  out.err = err;
85
85
  }
86
+ finally {
87
+ this.derandomizeInput(out.io.i);
88
+ }
89
+ }
90
+ derandomizeInput(input) {
91
+ for (const [k, v] of Object.entries(input)) {
92
+ if (Array.isArray(v)) {
93
+ v.forEach((vv, idx) => {
94
+ if (vv instanceof File) {
95
+ // @ts-ignore
96
+ input[k][idx] = this.derandomizeInputFile(vv);
97
+ }
98
+ });
99
+ }
100
+ else if (v instanceof File) {
101
+ // @ts-ignore
102
+ input[k] = this.derandomizeInputFile(v);
103
+ }
104
+ }
105
+ }
106
+ derandomizeInputFile(file) {
107
+ // Since TypeScript 5.8, a new `lastModified` field has appeared in `File.state: FileState {}` when snapshotting.
108
+ // The problem is that this value is a timestamp that changes everytime we execute the tests.
109
+ // Creating a `specificAssertion` just for that would be cumbersome.
110
+ // Hence the transform of the `File` into a deterministic `Object` for easy snapshotting.
111
+ return {
112
+ name: file.name,
113
+ size: file.size,
114
+ type: file.type,
115
+ };
86
116
  }
87
117
  };
88
118
  UCExecutor = UCExecutor_1 = __decorate([
@@ -0,0 +1,17 @@
1
+ import type { ErrorMessage } from '../../../dt/index.js';
2
+ import type { FSManager, Worker } from '../../../std/index.js';
3
+ import type { AppTesterCtx } from '../../ctx.js';
4
+ interface Input {
5
+ appPath: AppTesterCtx['appPath'];
6
+ }
7
+ interface Output {
8
+ errors: ErrorMessage[];
9
+ }
10
+ export declare class AppFolderChecker implements Worker<Input, Promise<Output>> {
11
+ private fsManager;
12
+ private output;
13
+ constructor(fsManager: FSManager);
14
+ exec({ appPath }: Input): Promise<Output>;
15
+ private makeSureSrcItemsAreAllowed;
16
+ }
17
+ export {};
@@ -0,0 +1,51 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { inject, injectable } from 'inversify';
14
+ import { APP_I18N_FILE_NAME, APP_INSTALLER_FILE_NAME, APP_MANIFEST_FILE_NAME, APP_SETTINGS_FILE_NAME, APP_SRC_DIR_NAME, APP_SRC_LIB_DIR_NAME, APP_SRC_UCDS_DIR_NAME, } from '../../../convention.js';
15
+ const ALLOWED_SRC_ITEMS = [
16
+ APP_SRC_LIB_DIR_NAME,
17
+ APP_SRC_UCDS_DIR_NAME,
18
+ APP_I18N_FILE_NAME,
19
+ APP_INSTALLER_FILE_NAME,
20
+ APP_MANIFEST_FILE_NAME,
21
+ APP_SETTINGS_FILE_NAME,
22
+ ];
23
+ const ERR_UNALLOWED_SRC_ITEM = (item) => `The app ${APP_SRC_DIR_NAME} folder should contain only the following items : ${ALLOWED_SRC_ITEMS.join(', ')} but found ${item}. Remove it or move it to 'lib'`;
24
+ let AppFolderChecker = class AppFolderChecker {
25
+ fsManager;
26
+ output;
27
+ constructor(fsManager) {
28
+ this.fsManager = fsManager;
29
+ this.output = { errors: [] };
30
+ }
31
+ async exec({ appPath }) {
32
+ const srcPath = this.fsManager.path(appPath, APP_SRC_DIR_NAME);
33
+ const contents = await this.fsManager.ls(srcPath);
34
+ const items = contents.map((i) => i.path);
35
+ this.makeSureSrcItemsAreAllowed(items);
36
+ return this.output;
37
+ }
38
+ makeSureSrcItemsAreAllowed(items) {
39
+ for (const item of items) {
40
+ if (!ALLOWED_SRC_ITEMS.includes(item)) {
41
+ this.output.errors.push(ERR_UNALLOWED_SRC_ITEM(item));
42
+ }
43
+ }
44
+ }
45
+ };
46
+ AppFolderChecker = __decorate([
47
+ injectable(),
48
+ __param(0, inject('FSManager')),
49
+ __metadata("design:paramtypes", [Object])
50
+ ], AppFolderChecker);
51
+ export { AppFolderChecker };
@@ -0,0 +1,2 @@
1
+ import type { PluginOption } from 'vite';
2
+ export declare const StripUCDLifecycleServerPlugin: PluginOption;
@@ -0,0 +1,18 @@
1
+ import { UC_DEF_FILE_NAME_SUFFIX } from '../../../convention.js';
2
+ import { stripUCDLifecycleServer } from '../../../uc/index.js';
3
+ export const StripUCDLifecycleServerPlugin = {
4
+ // Why enforce ?
5
+ // Otherwise Rollup parses the file and strips trailing commas.
6
+ // We need them to strip correctly (although the implementation will be made more robust).
7
+ enforce: 'pre',
8
+ name: 'strip-ucd-lifecycle-server',
9
+ transform: (src, id) => {
10
+ if (id.match(new RegExp(`${UC_DEF_FILE_NAME_SUFFIX}$`)) === null) {
11
+ return;
12
+ }
13
+ const code = stripUCDLifecycleServer(src);
14
+ return {
15
+ code,
16
+ };
17
+ },
18
+ };
@@ -1,6 +1,6 @@
1
- import { JoseJWTManager } from '../../index.std-jwt-manager-jose.js';
2
1
  import { FakeEmailManager } from '../../std/impl/FakeEmailManager.js';
3
2
  import { FakeJobManager } from '../../std/impl/FakeJobManager.js';
3
+ import { JoseJWTManager } from '../../std/impl/JoseJWTManager.js';
4
4
  export function bindServer(container) {
5
5
  // std
6
6
  container.bind('EmailManager').to(FakeEmailManager);
package/package.json CHANGED
@@ -1,12 +1,22 @@
1
1
  {
2
2
  "name": "libmodulor",
3
3
  "description": "An opinionated TypeScript library to create business oriented applications",
4
- "version": "0.6.1",
4
+ "version": "0.8.0",
5
5
  "license": "LGPL-3.0",
6
6
  "author": "Chafik H'nini <chafik.hnini@gmail.com>",
7
7
  "homepage": "https://github.com/c100k/libmodulor#readme",
8
8
  "bugs": "https://github.com/c100k/libmodulor/issues",
9
- "keywords": ["library", "typescript", "business application", "use case", "app", "product", "target", "auto-test", "auto-documentation"],
9
+ "keywords": [
10
+ "library",
11
+ "typescript",
12
+ "business application",
13
+ "use case",
14
+ "app",
15
+ "product",
16
+ "target",
17
+ "auto-test",
18
+ "auto-documentation"
19
+ ],
10
20
  "type": "module",
11
21
  "module": "./dist/esm/index.js",
12
22
  "exports": {
@@ -19,6 +29,9 @@
19
29
  "./locales/fr": {
20
30
  "import": "./dist/esm/i18n/locales/fr.js"
21
31
  },
32
+ "./node-express": {
33
+ "import": "./dist/esm/index.node-express.js"
34
+ },
22
35
  "./node-mcp": {
23
36
  "import": "./dist/esm/index.node-mcp.js"
24
37
  },
@@ -54,9 +67,16 @@
54
67
  }
55
68
  },
56
69
  "bin": "./dist/esm/products/Helper/index.js",
70
+ "scripts": {
71
+ "lint": "biome check --write .",
72
+ "lint:ci": "biome check"
73
+ },
74
+ "devDependencies": {
75
+ "@biomejs/biome": "^1.9.4"
76
+ },
57
77
  "peerDependencies": {
58
78
  "@hono/node-server": "^1.13.8",
59
- "@modelcontextprotocol/sdk": "^1.6.0",
79
+ "@modelcontextprotocol/sdk": "^1.6.1",
60
80
  "@stricli/core": "^1.1.1",
61
81
  "buffer": "^6.0.3",
62
82
  "cookie-parser": "^1.4.7",
@@ -64,7 +84,7 @@
64
84
  "express-fileupload": "^1.5.1",
65
85
  "fast-check": "^3.23.2",
66
86
  "helmet": "^8.0.0",
67
- "hono": "^4.7.2",
87
+ "hono": "^4.7.4",
68
88
  "inversify": "^6.2.2",
69
89
  "jose": "^6.0.8",
70
90
  "knex": "^3.1.0",
@@ -74,9 +94,9 @@
74
94
  "react-native": "^0.78.0",
75
95
  "reflect-metadata": "^0.2.2",
76
96
  "sqlite3": "^5.1.7",
77
- "typescript": "^5.7.3",
78
- "vite": "^6.2.0",
79
- "vitest": "^3.0.7"
97
+ "typescript": "^5.8.2",
98
+ "vite": "^6.2.1",
99
+ "vitest": "^3.0.8"
80
100
  },
81
101
  "peerDependenciesMeta": {
82
102
  "@hono/node-server": {
@@ -88,6 +108,18 @@
88
108
  "@stricli/core": {
89
109
  "optional": true
90
110
  },
111
+ "cookie-parser": {
112
+ "optional": true
113
+ },
114
+ "express": {
115
+ "optional": true
116
+ },
117
+ "express-fileupload": {
118
+ "optional": true
119
+ },
120
+ "helmet": {
121
+ "optional": true
122
+ },
91
123
  "hono": {
92
124
  "optional": true
93
125
  },
@@ -1,16 +0,0 @@
1
- ---
2
- name: Generic Issue
3
- about: Describe this issue template's purpose here.
4
- title: ''
5
- labels: ''
6
- assignees: ''
7
-
8
- ---
9
-
10
- ## Problem
11
-
12
- <!-- State the problem clearly with as much details as you can. It can be a new feature request or a bug. Either way, there should be a clear problem -->
13
-
14
- ## Potential Solution(s)
15
-
16
- <!-- If you have ideas, feel free to suggest them, we love it. We'll discuss the solutions and find the best one for everyone -->
@@ -1,19 +0,0 @@
1
- # To get started with Dependabot version updates, you'll need to specify which
2
- # package ecosystems to update and where the package manifests are located.
3
- # Please see the documentation for all configuration options:
4
- # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
-
6
- version: 2
7
- updates:
8
- - package-ecosystem: "npm"
9
- directory: "/"
10
- schedule:
11
- interval: "weekly"
12
- ignore:
13
- - dependency-name: "inversify"
14
- versions: ["7.x"]
15
- groups:
16
- dev:
17
- dependency-type: "development"
18
- prod:
19
- dependency-type: "production"