Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8921d59
Add parallel copy of extractor-v2
kingston Jun 10, 2025
1b8e27c
Rename types for template metadata
kingston Jun 10, 2025
cf474c2
Merge extractMetadata with writeTemplateFiles to extractTemplateFiles
kingston Jun 10, 2025
b9c3e8b
Remove sourceAbsolutePath
kingston Jun 10, 2025
6786b16
Extract out resolveTemplatePaths logic
kingston Jun 10, 2025
ced1905
Fix type errors
kingston Jun 10, 2025
303478f
Split out template extraction processes again
kingston Jun 10, 2025
4422c03
Implement remainder of TS extractor
kingston Jun 10, 2025
fba8d41
Fix remaining type errors
kingston Jun 10, 2025
63fb946
Enable extractor v2 for ts
kingston Jun 10, 2025
4293c50
Fix extraction logic
kingston Jun 10, 2025
b0e332c
Fix up various parts of extraction
kingston Jun 10, 2025
9682b42
Implement first iteration of ts extractor v2 on ts-utisl
kingston Jun 10, 2025
fde8dc6
Support barrel exports
kingston Jun 11, 2025
7890865
Switch over config.ts to the new system
kingston Jun 11, 2025
89cfed8
Convert logger service
kingston Jun 11, 2025
5d56d32
Fix up logger transformer
kingston Jun 11, 2025
5b9d2f6
Update error-handler-service to new model
kingston Jun 11, 2025
72bdbe6
Fix group usage
kingston Jun 11, 2025
5a5ae55
Add tests for config lookup
kingston Jun 11, 2025
a77bd4c
Add tests for barrel exports
kingston Jun 11, 2025
c8ead80
Fix up linting for barrel exports
kingston Jun 11, 2025
3eb2d23
Adjust to a standardized barrel export for generated files
kingston Jun 11, 2025
4fb3498
Fix tests and linting errors
kingston Jun 11, 2025
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: 4 additions & 0 deletions packages/core-generators/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"./renderers": {
"types": "./dist/renderers/types.d.ts",
"default": "./dist/renderers/index.js"
},
"./extractor-v2": {
"types": "./dist/renderers/typescript/extractor-v2/index.d.ts",
"default": "./dist/renderers/typescript/extractor-v2/index.js"
}
},
"main": "dist/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {
import { stringifyPrettyCompact } from '@baseplate-dev/utils';
import { z } from 'zod';

import type { TemplatePathRoot } from '#src/renderers/templates/plugins/template-paths/template-paths.plugin.js';
import type { TemplatePathRoot } from '#src/renderers/extractor/plugins/template-paths/template-paths.plugin.js';

import { projectScope } from '#src/providers/scopes.js';
import { TEMPLATE_PATHS_METADATA_FILE } from '#src/renderers/templates/plugins/template-paths/template-paths.plugin.js';
import { TEMPLATE_PATHS_METADATA_FILE } from '#src/renderers/extractor/plugins/template-paths/template-paths.plugin.js';

const descriptorSchema = z.object({});

Expand Down
2 changes: 1 addition & 1 deletion packages/core-generators/src/generators/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ export * from './eslint/eslint.generator.js';
export * from './node-git-ignore/node-git-ignore.generator.js';
export * from './node/node.generator.js';
export * from './prettier/prettier.generator.js';
export * from './ts-utils/ts-utils.generator.js';
export * from './ts-utils/index.js';
export * from './typescript/typescript.generator.js';
export * from './vitest/vitest.generator.js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "node/ts-utils",
"templates": {
"src/utils/arrays.ts": {
"name": "arrays",
"type": "ts",
"generator": "@baseplate-dev/core-generators#node/ts-utils",
"template": "",
"fileOptions": { "kind": "singleton" },
"projectExports": { "notEmpty": {} },
"pathRootRelativePath": "{src-root}/utils/arrays.ts",
"variables": {},
"importMapProviders": {}
},
"src/utils/normalize-types.ts": {
"name": "normalize-types",
"type": "ts",
"generator": "@baseplate-dev/core-generators#node/ts-utils",
"template": "",
"fileOptions": { "kind": "singleton" },
"projectExports": { "NormalizeTypes": { "isTypeOnly": true } },
"pathRootRelativePath": "{src-root}/utils/normalize-types.ts",
"variables": {},
"importMapProviders": {}
},
"src/utils/nulls.ts": {
"name": "nulls",
"type": "ts",
"generator": "@baseplate-dev/core-generators#node/ts-utils",
"template": "",
"fileOptions": { "kind": "singleton" },
"projectExports": { "restrictObjectNulls": {} },
"pathRootRelativePath": "{src-root}/utils/nulls.ts",
"variables": {},
"importMapProviders": {}
},
"src/utils/string.ts": {
"name": "string",
"type": "ts",
"generator": "@baseplate-dev/core-generators#node/ts-utils",
"template": "",
"fileOptions": { "kind": "singleton" },
"projectExports": { "capitalizeString": {} },
"pathRootRelativePath": "{src-root}/utils/string.ts",
"variables": {},
"importMapProviders": {}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { NODE_TS_UTILS_PATHS } from './template-paths.js';
import { NODE_TS_UTILS_IMPORTS } from './ts-import-providers.js';
import { NODE_TS_UTILS_TEMPLATES } from './typed-templates.js';

export const NODE_TS_UTILS_GENERATED = {
imports: NODE_TS_UTILS_IMPORTS,
paths: NODE_TS_UTILS_PATHS,
templates: NODE_TS_UTILS_TEMPLATES,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { createGeneratorTask, createProviderType } from '@baseplate-dev/sync';

import { packageInfoProvider } from '#src/providers/project.js';

export interface NodeTsUtilsPaths {
arrays: string;
normalizeTypes: string;
nulls: string;
string: string;
}

const nodeTsUtilsPaths = createProviderType<NodeTsUtilsPaths>(
'node-ts-utils-paths',
);

const nodeTsUtilsPathsTask = createGeneratorTask({
dependencies: { packageInfo: packageInfoProvider },
exports: { nodeTsUtilsPaths: nodeTsUtilsPaths.export() },
run({ packageInfo }) {
const srcRoot = packageInfo.getPackageSrcPath();

return {
providers: {
nodeTsUtilsPaths: {
arrays: `${srcRoot}/utils/arrays.ts`,
normalizeTypes: `${srcRoot}/utils/normalize-types.ts`,
nulls: `${srcRoot}/utils/nulls.ts`,
string: `${srcRoot}/utils/string.ts`,
},
},
};
},
});

export const NODE_TS_UTILS_PATHS = {
provider: nodeTsUtilsPaths,
task: nodeTsUtilsPathsTask,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import {
createGeneratorTask,
createReadOnlyProviderType,
} from '@baseplate-dev/sync';

import type { TsImportMapProviderFromSchema } from '#src/renderers/typescript/index.js';

import { projectScope } from '#src/providers/index.js';
import {
createTsImportMap,
createTsImportMapSchema,
} from '#src/renderers/typescript/index.js';

import { NODE_TS_UTILS_PATHS } from './template-paths.js';

const tsUtilsImportsSchema = createTsImportMapSchema({
capitalizeString: {},
NormalizeTypes: { isTypeOnly: true },
notEmpty: {},
restrictObjectNulls: {},
});

export type TsUtilsImportsProvider = TsImportMapProviderFromSchema<
typeof tsUtilsImportsSchema
>;

export const tsUtilsImportsProvider =
createReadOnlyProviderType<TsUtilsImportsProvider>('ts-utils-imports');

const nodeTsUtilsImportsTask = createGeneratorTask({
dependencies: {
paths: NODE_TS_UTILS_PATHS.provider,
},
exports: {
imports: tsUtilsImportsProvider.export(projectScope),
},
run({ paths }) {
return {
providers: {
imports: createTsImportMap(tsUtilsImportsSchema, {
capitalizeString: paths.string,
NormalizeTypes: paths.normalizeTypes,
notEmpty: paths.arrays,
restrictObjectNulls: paths.nulls,
}),
},
};
},
});

export const NODE_TS_UTILS_IMPORTS = {
task: nodeTsUtilsImportsTask,
};

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import path from 'node:path';

import { createTsTemplateFile } from '#src/renderers/typescript/templates/types.js';

const arrays = createTsTemplateFile({
fileOptions: { kind: 'singleton' },
importMapProviders: {},
name: 'arrays',
projectExports: { notEmpty: {} },
source: {
path: path.join(import.meta.dirname, '../templates/src/utils/arrays.ts'),
},
variables: {},
});

const normalizeTypes = createTsTemplateFile({
fileOptions: { kind: 'singleton' },
importMapProviders: {},
name: 'normalize-types',
projectExports: { NormalizeTypes: { isTypeOnly: true } },
source: {
path: path.join(
import.meta.dirname,
'../templates/src/utils/normalize-types.ts',
),
},
variables: {},
});

const nulls = createTsTemplateFile({
fileOptions: { kind: 'singleton' },
importMapProviders: {},
name: 'nulls',
projectExports: { restrictObjectNulls: {} },
source: {
path: path.join(import.meta.dirname, '../templates/src/utils/nulls.ts'),
},
variables: {},
});

const string = createTsTemplateFile({
fileOptions: { kind: 'singleton' },
importMapProviders: {},
name: 'string',
projectExports: { capitalizeString: {} },
source: {
path: path.join(import.meta.dirname, '../templates/src/utils/string.ts'),
},
variables: {},
});

export const NODE_TS_UTILS_TEMPLATES = {
arrays,
normalizeTypes,
nulls,
string,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type { TsUtilsImportsProvider } from './generated/ts-import-providers.js';
export { tsUtilsImportsProvider } from './generated/ts-import-providers.js';
export * from './ts-utils.generator.js';

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,52 +1,34 @@
import type { TemplateFileSource } from '@baseplate-dev/sync';

import { createGenerator, createGeneratorTask } from '@baseplate-dev/sync';
import path from 'node:path';
import { z } from 'zod';

import { projectScope } from '#src/providers/scopes.js';

import { typescriptFileProvider } from '../typescript/typescript.generator.js';
import {
createTsUtilsImports,
tsUtilsImportsProvider,
} from './generated/ts-import-maps.js';
import { NODE_TS_UTILS_TS_TEMPLATES } from './generated/ts-templates.js';
import { NODE_TS_UTILS_GENERATED } from './generated/index.js';

const descriptorSchema = z.object({});

function getUtilsPath(source: TemplateFileSource): string {
if (!('path' in source)) {
throw new Error('Template path is required');
}
return path.join('@/src/utils', source.path);
}

type TsUtilKey = keyof typeof NODE_TS_UTILS_TS_TEMPLATES;
type TsUtilKey = keyof typeof NODE_TS_UTILS_GENERATED.templates;

export const tsUtilsGenerator = createGenerator({
name: 'node/ts-utils',
generatorFileUrl: import.meta.url,
descriptorSchema,
buildTasks: () => ({
paths: NODE_TS_UTILS_GENERATED.paths.task,
imports: NODE_TS_UTILS_GENERATED.imports.task,
main: createGeneratorTask({
dependencies: {
typescriptFile: typescriptFileProvider,
paths: NODE_TS_UTILS_GENERATED.paths.provider,
},
exports: {
tsUtilsImports: tsUtilsImportsProvider.export(projectScope),
},
run({ typescriptFile }) {
run({ typescriptFile, paths }) {
return {
providers: {
tsUtilsImports: createTsUtilsImports('@/src/utils'),
},
build: (builder) => {
for (const key of Object.keys(NODE_TS_UTILS_TS_TEMPLATES)) {
const template = NODE_TS_UTILS_TS_TEMPLATES[key as TsUtilKey];
for (const key of Object.keys(NODE_TS_UTILS_GENERATED.templates)) {
const template =
NODE_TS_UTILS_GENERATED.templates[key as TsUtilKey];
typescriptFile.addLazyTemplateFile({
template,
destination: getUtilsPath(template.source),
destination: paths[key as TsUtilKey],
generatorInfo: builder.generatorInfo,
});
}
Expand All @@ -56,6 +38,3 @@ export const tsUtilsGenerator = createGenerator({
}),
}),
});

export { tsUtilsImportsProvider } from './generated/ts-import-maps.js';
export type { TsUtilsImportsProvider } from './generated/ts-import-maps.js';
Loading