Skip to content

Commit 726ee1a

Browse files
committed
Changed from cjs to esm.
1 parent 3b63ee1 commit 726ee1a

41 files changed

Lines changed: 276 additions & 181 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

codify-core/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"@oclif/plugin-help": "^5",
99
"@oclif/plugin-plugins": "^3.8.4",
1010
"eslint-config-prettier": "^9.0.0",
11-
"semver": "^7.5.4"
11+
"semver": "^7.5.4",
12+
"codify-schemas": "1.0.24",
13+
"ajv": "^8.12.0"
1214
},
1315
"description": "Codify is a set up as code tool for developers",
1416
"devDependencies": {
@@ -30,7 +32,8 @@
3032
"oclif": "^4.0.0",
3133
"shx": "^0.3.3",
3234
"ts-node": "^10.9.1",
33-
"typescript": "^5"
35+
"typescript": "^5",
36+
"vitest": "^1.4.0"
3437
},
3538
"engines": {
3639
"node": ">=18.0.0"
@@ -45,6 +48,7 @@
4548
"license": "MIT",
4649
"main": "dist/index.js",
4750
"name": "codify",
51+
"type": "module",
4852
"oclif": {
4953
"bin": "codify",
5054
"dirname": "codify",

codify-core/src/commands/plan/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('temp tests', async () => {
2929
}
3030
})
3131

32-
let sleep = async ms => new Promise(resolve => setTimeout(resolve, ms));
32+
let sleep = async (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
3333
await sleep(5000)
3434

3535
done()

codify-core/src/commands/plan/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Args, Command, Flags } from '@oclif/core'
22
import * as path from 'node:path';
33

4-
import { PlanOrchestrator } from './orchestrator';
4+
import { PlanOrchestrator } from './orchestrator.js';
55

66
export default class Plan extends Command {
77
static args = {

codify-core/src/commands/plan/orchestrator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ConfigCompiler } from '../../config-compiler';
2-
import { PluginCollection } from '../../plugins/plugin-collection';
1+
import { ConfigCompiler } from '../../config-compiler/index.js';
2+
import { PluginCollection } from '../../plugins/plugin-collection.js';
33

44
export const PlanOrchestrator = {
55
async run(rootDirectory: string): Promise<string> {

codify-core/src/config-compiler/index.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { ResourceDefinitions } from '../plugins/entities/definitions/resource';
2-
import { InternalError } from '../utils/errors';
3-
import { ConfigClass } from './language-definition';
4-
import { ConfigLoader } from './loader';
5-
import { DependencyGraphBuilder } from './output-generator/dependency-graph-builder';
6-
import { CompiledProject } from './output-generator/entities/compiled-project';
7-
import { CompiledProjectTransformer } from './output-generator/transformer';
8-
import { FileParser } from './parser';
9-
import { ProjectConfig } from './parser/entities/configs/project';
10-
import { ParsedModule } from './parser/entities/parsed-module';
11-
import { ParsedProject } from './parser/entities/parsed-project';
12-
import { JsonFileParser } from './parser/json/file-parser';
1+
import { ResourceDefinitions } from '../plugins/entities/definitions/resource.js';
2+
import { InternalError } from '../utils/errors.js';
3+
import { ConfigClass } from './language-definition.js';
4+
import { ConfigLoader } from './loader/index.js';
5+
import { DependencyGraphBuilder } from './output-generator/dependency-graph-builder.js';
6+
import { CompiledProject } from './output-generator/entities/compiled-project.js';
7+
import { CompiledProjectTransformer } from './output-generator/transformer.js';
8+
import { ProjectConfig } from './parser/entities/configs/project.js';
9+
import { ParsedModule } from './parser/entities/parsed-module.js';
10+
import { ParsedProject } from './parser/entities/parsed-project.js';
11+
import { FileParser } from './parser/index.js';
12+
import { JsonFileParser } from './parser/json/file-parser.js';
1313

1414
export class ConfigCompiler {
1515

@@ -31,8 +31,8 @@ export class ConfigCompiler {
3131
const configBlocks = configBlocksResult.flat(1);
3232

3333
const parsedProjectConfigs = configBlocks.filter((u) => u.configClass === ConfigClass.PROJECT);
34-
if (parsedProjectConfigs.length !== 1) {
35-
throw new Error('One one project config can be specified');
34+
if (parsedProjectConfigs.length > 1) {
35+
throw new Error('One or zero project config can be specified');
3636
}
3737

3838
const projectConfig = parsedProjectConfigs[0] as ProjectConfig;

codify-core/src/config-compiler/loader/entities/file.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RemoveMethods } from '../../../utils/types';
1+
import { RemoveMethods } from '../../../utils/types.js';
22

33
export class LoadedFile {
44
contents!: string;

codify-core/src/config-compiler/loader/entities/module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { RemoveMethods } from '../../../utils/types';
2-
import { LoadedFile } from './file';
1+
import { RemoveMethods } from '../../../utils/types.js';
2+
import { LoadedFile } from './file.js';
33

44
export class LoadedModule {
55
directory!: string;

codify-core/src/config-compiler/loader/entities/project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LoadedModule } from './module';
1+
import { LoadedModule } from './module.js';
22

33
export interface LoadedProject {
44
coreModule: LoadedModule;

codify-core/src/config-compiler/loader/index.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as mock from 'mock-fs';
22
import { deepEqual, equal } from 'node:assert';
33

4-
import { LoadedFile } from './entities/file';
5-
import { ConfigLoader } from './index';
4+
import { LoadedFile } from './entities/file.js';
5+
import { ConfigLoader } from './index.js';
66

77
describe('Config loader tests', () => {
88
let parser: ConfigLoader;
@@ -20,7 +20,7 @@ describe('Config loader tests', () => {
2020
'providers.json': '[]'
2121
}
2222
};
23-
mock(config);
23+
(mock as any)(config);
2424

2525
const project = await parser.loadProject(dir);
2626

codify-core/src/config-compiler/loader/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import * as fs from 'node:fs/promises';
22
import * as path from 'node:path';
33

4-
import { ConfigCompiler } from '../index';
5-
import { LoadedFile } from './entities/file';
6-
import { LoadedModule } from './entities/module';
7-
import { LoadedProject } from './entities/project';
4+
import { ConfigCompiler } from '../index.js';
5+
import { LoadedFile } from './entities/file.js';
6+
import { LoadedModule } from './entities/module.js';
7+
import { LoadedProject } from './entities/project.js';
88

99
/**
1010
* This class loads relevant files in the project directory into memory so that they can be compiled
11+
* TODO: Rename this to reader. A loader has a different meaning for compilers
1112
*/
1213
export class ConfigLoader {
1314

0 commit comments

Comments
 (0)