@powerhousedao/codegen 6.1.0-dev.2 → 6.1.0-dev.20
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/dist/{file-builders-BGuRLZmo.mjs → file-builders-DYqyzzbb.mjs} +67 -45
- package/dist/file-builders-DYqyzzbb.mjs.map +1 -0
- package/dist/{index-DGqqrenJ.d.mts → index-DqWWfHAz.d.mts} +15 -2
- package/dist/index-DqWWfHAz.d.mts.map +1 -0
- package/dist/index.d.mts +11 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +319 -188
- package/dist/index.mjs.map +1 -1
- package/dist/src/file-builders/index.d.mts +2 -2
- package/dist/src/file-builders/index.mjs +2 -2
- package/dist/src/name-builders/index.d.mts +1 -1
- package/dist/src/name-builders/index.mjs +1 -1
- package/dist/src/templates/index.d.mts +13 -3
- package/dist/src/templates/index.d.mts.map +1 -1
- package/dist/src/templates/index.mjs +1 -1
- package/dist/src/utils/index.d.mts +1 -1
- package/dist/src/utils/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/file-builders-BGuRLZmo.mjs.map +0 -1
- package/dist/index-DGqqrenJ.d.mts.map +0 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ANALYTICS_ENGINE_CORE_PACKAGE, BOILERPLATE_ALLOWED_BUILDS, GRAPHQL_PACKAGE, GRAPHQL_TAG_PACKAGE, PEER_EXTERNAL_DEPENDENCIES, REACTOR_API_PACKAGE, VERSIONED_DEV_DEPENDENCIES, VERSIONED_PEER_DEPENDENCIES, defaultManifest, directoryExists, externalDevDependencies, fileExists, fileExistsSync, isDirectory, makeVersionedDependenciesMap, packageJsonExports, spawnAsync, writeFileEnsuringDir } from "@powerhousedao/shared/clis";
|
|
1
|
+
import { ANALYTICS_ENGINE_CORE_PACKAGE, BOILERPLATE_ALLOWED_BUILDS, BOILERPLATE_PNPM_OVERRIDES, GRAPHQL_PACKAGE, GRAPHQL_TAG_PACKAGE, PEER_EXTERNAL_DEPENDENCIES, REACTOR_API_PACKAGE, VERSIONED_DEV_DEPENDENCIES, VERSIONED_PEER_DEPENDENCIES, defaultManifest, directoryExists, externalDevDependencies, fileExists, fileExistsSync, isDirectory, makeVersionedDependenciesMap, packageJsonExports, spawnAsync, writeFileEnsuringDir } from "@powerhousedao/shared/clis";
|
|
2
2
|
import { readdirSync } from "fs";
|
|
3
3
|
import path, { join } from "path";
|
|
4
4
|
import { DocumentModelGlobalStateSchema, ManifestSchema } from "@powerhousedao/shared/document-model";
|
|
5
5
|
import fs, { copyFile, mkdir, readdir, writeFile } from "node:fs/promises";
|
|
6
6
|
import { camelCase, capitalCase, constantCase, kebabCase, pascalCase } from "change-case";
|
|
7
|
+
import { DEFAULT_CONNECT_CONFIG } from "@powerhousedao/shared/connect";
|
|
7
8
|
import { DEFAULT_REGISTRY_URL } from "@powerhousedao/shared/registry";
|
|
8
9
|
import { capitalize, concat, conditional, constant, endsWith, filter, find, first, flatMap, forEach, isDefined, isIncludedIn, isNonNullish, isNot, isStrictEqual, isString, isTruthy, last, map, mapValues, merge, pipe, prop, sort, split, startsWith, subtract, unique, uniqueBy, when } from "remeda";
|
|
9
10
|
import { IndentationText, Project, SyntaxKind, VariableDeclarationKind, ts } from "ts-morph";
|
|
@@ -11,11 +12,11 @@ import arg from "arg";
|
|
|
11
12
|
import { format } from "prettier";
|
|
12
13
|
import { z } from "zod";
|
|
13
14
|
import { loadJsonFile, loadJsonFileSync } from "load-json-file";
|
|
15
|
+
import { writeJsonFile } from "write-json-file";
|
|
14
16
|
import { stripVTControlCharacters } from "node:util";
|
|
15
17
|
import path$1, { join as join$1, relative } from "node:path";
|
|
16
18
|
import { generate } from "@graphql-codegen/cli";
|
|
17
19
|
import { generatorTypeDefs, validationSchema } from "@powerhousedao/document-engineering/graphql";
|
|
18
|
-
import { writeJsonFile } from "write-json-file";
|
|
19
20
|
function isEOL(c) {
|
|
20
21
|
return c === 10 || c === 13;
|
|
21
22
|
}
|
|
@@ -4513,7 +4514,7 @@ const packageJsonTemplate = (projectName, peerDependencies, devDependencies) =>
|
|
|
4513
4514
|
}
|
|
4514
4515
|
}
|
|
4515
4516
|
`.raw;
|
|
4516
|
-
const pnpmWorkspaceTemplate = `allowBuilds:\n${BOILERPLATE_ALLOWED_BUILDS.map((pkg) => ` ${/[@/]/.test(pkg) ? `"${pkg}"` : pkg}: true`).join("\n")}\n`;
|
|
4517
|
+
const pnpmWorkspaceTemplate = `allowBuilds:\n${BOILERPLATE_ALLOWED_BUILDS.map((pkg) => ` ${/[@/]/.test(pkg) ? `"${pkg}"` : pkg}: true`).join("\n")}\noverrides:\n${Object.entries(BOILERPLATE_PNPM_OVERRIDES).map(([pkg, version]) => ` ${/[@/]/.test(pkg) ? `"${pkg}"` : pkg}: "${version}"`).join("\n")}\n`;
|
|
4517
4518
|
//#endregion
|
|
4518
4519
|
//#region src/templates/boilerplate/package.json.legacy.ts
|
|
4519
4520
|
const packageJsonScriptsTemplate = {
|
|
@@ -4570,34 +4571,33 @@ const packageJsonExportsTemplate = {
|
|
|
4570
4571
|
};
|
|
4571
4572
|
//#endregion
|
|
4572
4573
|
//#region src/templates/boilerplate/powerhouse.config.json.ts
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
}
|
|
4574
|
+
/**
|
|
4575
|
+
* Render the `powerhouse.config.json` scaffolded into newly-created projects
|
|
4576
|
+
* by `ph init`.
|
|
4577
|
+
*
|
|
4578
|
+
* The `connect` block is populated from `DEFAULT_CONNECT_CONFIG` so every
|
|
4579
|
+
* runtime field is present in the scaffolded file. Dev consumers that read
|
|
4580
|
+
* the source config directly (notably `ph vetra`, which has no dist file)
|
|
4581
|
+
* see fully-defined values instead of `undefined`.
|
|
4582
|
+
*/
|
|
4583
4583
|
async function buildPowerhouseConfigTemplate(args) {
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
}
|
|
4600
|
-
|
|
4584
|
+
const config = {
|
|
4585
|
+
$schema: "https://raw.githubusercontent.com/powerhouse-inc/powerhouse/main/packages/shared/clis/source-config.schema.json",
|
|
4586
|
+
documentModelsDir: "./document-models",
|
|
4587
|
+
editorsDir: "./editors",
|
|
4588
|
+
processorsDir: "./processors",
|
|
4589
|
+
subgraphsDir: "./subgraphs",
|
|
4590
|
+
studio: { port: 3e3 },
|
|
4591
|
+
reactor: { port: 4001 },
|
|
4592
|
+
packages: [],
|
|
4593
|
+
packageRegistryUrl: DEFAULT_REGISTRY_URL,
|
|
4594
|
+
connect: DEFAULT_CONNECT_CONFIG
|
|
4595
|
+
};
|
|
4596
|
+
if (args.remoteDrive) config.vetra = {
|
|
4597
|
+
driveId: args.remoteDrive.split("/").pop() ?? "",
|
|
4598
|
+
driveUrl: args.remoteDrive
|
|
4599
|
+
};
|
|
4600
|
+
return `${JSON.stringify(config, null, 2)}\n`;
|
|
4601
4601
|
}
|
|
4602
4602
|
//#endregion
|
|
4603
4603
|
//#region src/templates/boilerplate/powerhouse.manifest.json.ts
|
|
@@ -4816,8 +4816,9 @@ Next Steps:
|
|
|
4816
4816
|
//#endregion
|
|
4817
4817
|
//#region src/templates/boilerplate/style.css.ts
|
|
4818
4818
|
const styleTemplate = css`
|
|
4819
|
-
@import "tailwindcss";
|
|
4820
4819
|
@import "@powerhousedao/design-system/theme.css";
|
|
4820
|
+
@custom-variant dark (&:where(.dark, .dark *));
|
|
4821
|
+
@import "tailwindcss";
|
|
4821
4822
|
@import "@powerhousedao/connect/style.css";
|
|
4822
4823
|
|
|
4823
4824
|
@theme {
|
|
@@ -5851,12 +5852,11 @@ const documentModelGenUtilsTemplate = (v) => ts$1`
|
|
|
5851
5852
|
import type {
|
|
5852
5853
|
DocumentModelUtils,
|
|
5853
5854
|
} from "document-model";
|
|
5854
|
-
import {
|
|
5855
|
+
import {
|
|
5855
5856
|
baseCreateDocument,
|
|
5856
5857
|
baseSaveToFileHandle,
|
|
5857
5858
|
baseLoadFromInput,
|
|
5858
5859
|
defaultBaseState,
|
|
5859
|
-
generateId,
|
|
5860
5860
|
} from "document-model";
|
|
5861
5861
|
import { reducer } from './reducer.js';
|
|
5862
5862
|
import { ${v.documentTypeVariableName} } from "./document-type.js";
|
|
@@ -5877,17 +5877,11 @@ export const utils: DocumentModelUtils<${v.phStateName}> = {
|
|
|
5877
5877
|
return { ...defaultBaseState(), global: { ...initialGlobalState, ...state?.global }, local: { ...initialLocalState, ...state?.local } };
|
|
5878
5878
|
},
|
|
5879
5879
|
createDocument(state) {
|
|
5880
|
-
|
|
5880
|
+
return baseCreateDocument(
|
|
5881
5881
|
utils.createState,
|
|
5882
|
-
state
|
|
5882
|
+
state,
|
|
5883
|
+
${v.documentTypeVariableName}
|
|
5883
5884
|
);
|
|
5884
|
-
|
|
5885
|
-
document.header.documentType = ${v.documentTypeVariableName};
|
|
5886
|
-
|
|
5887
|
-
// for backwards compatibility, but this is NOT a valid signed document id
|
|
5888
|
-
document.header.id = generateId();
|
|
5889
|
-
|
|
5890
|
-
return document;
|
|
5891
5885
|
},
|
|
5892
5886
|
saveToFileHandle(document, input) {
|
|
5893
5887
|
return baseSaveToFileHandle(document, input);
|
|
@@ -7255,13 +7249,41 @@ async function writeProjectRootFiles(args, projectDir = process.cwd()) {
|
|
|
7255
7249
|
tag,
|
|
7256
7250
|
version
|
|
7257
7251
|
});
|
|
7258
|
-
await createOrUpdateManifest({ name }, projectDir);
|
|
7259
7252
|
await writeFileEnsuringDir("powerhouse.config.json", await buildPowerhouseConfigTemplate({
|
|
7260
7253
|
tag,
|
|
7261
7254
|
version,
|
|
7262
7255
|
remoteDrive
|
|
7263
7256
|
}));
|
|
7264
7257
|
await writeFileEnsuringDir("package.json", packageJson);
|
|
7258
|
+
await applyProjectCustomizations({
|
|
7259
|
+
name,
|
|
7260
|
+
projectDir
|
|
7261
|
+
});
|
|
7262
|
+
}
|
|
7263
|
+
/**
|
|
7264
|
+
* Per-project customizations applied to a project directory — the parts
|
|
7265
|
+
* `ph init` derives from the project name. Shared by the fresh-scaffold path
|
|
7266
|
+
* ({@link writeProjectRootFiles}) and the `--template` clone path, so future
|
|
7267
|
+
* per-project customizations only need to be added here once.
|
|
7268
|
+
*
|
|
7269
|
+
* Assumes `package.json` already exists in `projectDir`.
|
|
7270
|
+
*/
|
|
7271
|
+
async function applyProjectCustomizations(args) {
|
|
7272
|
+
const { name, projectDir, remoteDrive } = args;
|
|
7273
|
+
const pkgPath = join(projectDir, "package.json");
|
|
7274
|
+
const pkg = await loadJsonFile(pkgPath);
|
|
7275
|
+
pkg.name = name;
|
|
7276
|
+
await writeJsonFile(pkgPath, pkg, { indent: 2 });
|
|
7277
|
+
await createOrUpdateManifest({ name }, projectDir);
|
|
7278
|
+
if (remoteDrive) {
|
|
7279
|
+
const configPath = join(projectDir, "powerhouse.config.json");
|
|
7280
|
+
const config = await loadJsonFile(configPath);
|
|
7281
|
+
config.vetra = {
|
|
7282
|
+
driveId: remoteDrive.split("/").pop() ?? "",
|
|
7283
|
+
driveUrl: remoteDrive
|
|
7284
|
+
};
|
|
7285
|
+
await writeJsonFile(configPath, config, { indent: 2 });
|
|
7286
|
+
}
|
|
7265
7287
|
}
|
|
7266
7288
|
async function writeCIFiles(projectDir = process.cwd()) {
|
|
7267
7289
|
await writeFileEnsuringDir(join(projectDir, ".github/workflows/sync-and-publish.yml"), syncAndPublishWorkflowTemplate);
|
|
@@ -8537,6 +8559,6 @@ async function makeSubgraphsIndexFile(args) {
|
|
|
8537
8559
|
await formatSourceFileWithPrettier(sourceFile);
|
|
8538
8560
|
}
|
|
8539
8561
|
//#endregion
|
|
8540
|
-
export {
|
|
8562
|
+
export { buildObjectLiteral as $, connectEntrypointTemplate as $n, documentModelOperationModuleActionsFileTemplate as $t, writeGeneratedSubgraphsFiles as A, packageJsonScriptsTemplate as An, analyticsIndexTemplate as At, DEFAULT_PROJECT_OPTIONS as B, indexHtmlTemplate as Bn, documentModelSrcUtilsTemplate as Bt, writeAiConfigFiles as C, tsconfigPathsTemplate as Cn, relationalDbMigrationsTemplate as Ct, writeGeneratedEditorsFiles as D, ManifestTemplate as Dn, processorsFactoryTemplate as Dt, writeGeneratedDocumentModelsFiles as E, readmeTemplate as En, processorsIndexTemplate as Et, makeEditorsFile as F, mcpTemplate as Fn, documentModelOperationsModuleTestFileTemplate as Ft, getBooleanPropertyValue as G, editorsIndexTemplate as Gn, documentModelGenUtilsTemplate as Gt, getDefaultProjectOptions as H, syncAndPublishWorkflowTemplate as Hn, documentModelModuleFileTemplate as Ht, makeEditorsIndexFile as I, mainTsxTemplate as In, makeOperationImportNames as It, getProperyAssignmentByName as J, documentModelsIndexTemplate as Jn, documentModelGenReducerFileTemplate as Jt, getObjectLiteral as K, editorsTemplate as Kn, documentModelGenTypesTemplate as Kt, validateDocumentModelState as L, licenseTemplate as Ln, makeOperationsImports as Lt, writeProjectRootFiles as M, exportsTemplate as Mn, documentModelUtilsTemplate as Mt, tsMorphGenerateApp as N, packageJsonTemplate as Nn, upgradeTransitionTemplate as Nt, writeGeneratedProcessorsFiles as O, buildPowerhouseConfigTemplate as On, factoryBuildersTemplate as Ot, makeEditorModuleFile as P, npmrcTemplate as Pn, upgradeManifestTemplate as Pt, loadDocumentModelInDir as Q, dockerfileTemplate as Qn, documentModelOperationsModuleCreatorsFileTemplate as Qt, updateVersionedImports as R, indexTsTemplate as Rn, makeTestCaseForOperation as Rt, applyProjectCustomizations as S, tsConfigTemplate as Sn, relationalDbProcessorTemplate as St, writeCIFiles as T, styleTemplate as Tn, relationalDbFactoryTemplate as Tt, getAllImportModuleSpecifiers as U, geminiSettingsTemplate as Un, documentModelIndexTemplate as Ut, buildTsMorphProject as V, gitIgnoreTemplate as Vn, documentModelSrcIndexFileTemplate as Vt, getAllImportNames as W, eslintConfigTemplate as Wn, documentModelHooksFileTemplate as Wt, getStringPropertyValue as X, switchboardEntrypointTemplate as Xn, documentModelOperationsModuleOperationsFileTemplate as Xt, getStringArrayPropertyElements as Y, documentModelsTemplate as Yn, documentModelPhFactoriesFileTemplate as Yt, getVariableDeclarationByTypeName as Z, nginxConfTemplate as Zn, documentModelOperationsModuleErrorFileTemplate as Zt, getCommandHelpInfo as _, documentModelRootActionsFileTemplate as _n, customSubgraphResolversTemplate as _t, getOrCreateManifestFile as a, getLatestDocumentModelSpec as an, driveExplorerNavigationBreadcrumbsFileTemplate as ar, getSubgraphMetadata as at, writeCliDocsMarkdownFile as b, docsFromCliHelpTemplate as bn, subgraphIndexFileTemplate as bt, operationHasAttachment as c, getActionInputTypeNames as cn, appFilesFileTemplate as cr, getEditorMetadata as ct, tsMorphGenerateDocumentModel as d, documentModelGenIndexFileTemplate as dn, appDriveContentsFileTemplate as dr, runPrettier as dt, getModuleExportType as en, cursorMcpTemplate as er, buildStringLiteral as et, generateDocumentModelZodSchemas as f, documentModelDocumentTypeTemplate as fn, createDocumentFileTemplate as fr, getDocumentTypeMetadata as ft, tsMorphGenerateDocumentEditor as g, documentModelGenActionsFileTemplate as gn, parseConfig as gt, scalarsValidation as h, documentModelGenControllerFileTemplate as hn, parseArgs as ht, createOrUpdateManifest as i, getEditorVariableNames as in, appConfigFileTemplate as ir, getPreviousVersionSourceFile as it, writeModuleFiles as j, pnpmWorkspaceTemplate as jn, analyticsFactoryTemplate as jt, writeGeneratedProjectRootFiles as k, packageJsonExportsTemplate as kn, analyticsProcessorTemplate as kt, operationHasEmptyInput as l, getActionType as ln, emptyStateFileTemplate as lr, formatSafe as lt, scalars as m, documentModelGenCreatorsFileTemplate as mn, configSpec as mt, tsMorphGenerateSubgraph as n, getDocumentModelSpecByVersionNumber as nn, agentsTemplate as nr, getOrCreateDirectory as nt, pruneManifestSection as o, getLatestDocumentModelSpecVersionNumber as on, folderTreeFileTemplate as or, getProcessorMetadata as ot, generateTypesAndZodSchemasFromGraphql as p, documentModelDocumentSchemaFileTemplate as pn, documentModelDocumentTypeMetadata as pt, getObjectProperty as q, upgradeManifestsTemplate as qn, documentModelSchemaIndexTemplate as qt, tsMorphGenerateProcessor as r, getDocumentModelVariableNames as rn, appEditorFileTemplate as rr, getOrCreateSourceFile as rt, makeModulesIndexFile as s, getActionInputName as sn, appFoldersFileTemplate as sr, getAppMetadata as st, makeSubgraphsIndexFile as t, getDocumentModelDirName as tn, claudeSettingsLocalTemplate as tr, ensureDirectoriesExist as tt, operationHasInput as u, getActionTypeName as un, driveExplorerFileTemplate as ur, formatSourceFileWithPrettier as ut, getCommandsHelpInfo as v, documentEditorModuleFileTemplate as vn, customSubgraphSchemaTemplate as vt, writeAllGeneratedProjectFiles as w, subgraphsIndexTemplate as wn, relationalDbIndexTemplate as wt, buildBoilerplatePackageJson as x, vitestConfigTemplate as xn, relationalDbSchemaTemplate as xt, makeCliDocsFromHelp as y, documentEditorEditorFileTemplate as yn, subgraphLibFileTemplate as yt, getInitialStates as z, legacyIndexHtmlTemplate as zn, documentModelTestFileTemplate as zt };
|
|
8541
8563
|
|
|
8542
|
-
//# sourceMappingURL=file-builders-
|
|
8564
|
+
//# sourceMappingURL=file-builders-DYqyzzbb.mjs.map
|