@dbx-tools/projen 0.6.9 → 0.6.10

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/index.ts CHANGED
@@ -15,6 +15,7 @@ export * as packages from "./src/packages.ts";
15
15
  export * as pnpmWorkspace from "./src/pnpm-workspace.ts";
16
16
  export * as project from "./src/project.ts";
17
17
  export * as projectPredicate from "./src/project-predicate.ts";
18
+ export * as publish from "./src/publish.ts";
18
19
  export * as release from "./src/release.ts";
19
20
  export * as scaffold from "./src/scaffold.ts";
20
21
  export * as tags from "./src/tags.ts";
@@ -22,75 +23,24 @@ export * as tsconfig from "./src/tsconfig.ts";
22
23
  export * as vite from "./src/vite.ts";
23
24
  export * as vscode from "./src/vscode.ts";
24
25
  export * as watch from "./src/watch.ts";
25
- export { generateBarrels } from "./src/barrels.ts";
26
- export { listGeneratedFiles, listNodeModulesDirs, removePaths } from "./src/clean.ts";
27
- export { generateCodegen } from "./src/codegen.ts";
28
26
  export { DBXToolsConfig } from "./src/dbx-tools-config.ts";
29
27
  export type { DBXToolsConfigOptions } from "./src/dbx-tools-config.ts";
30
28
  export { resolvePkgRoot } from "./src/engine-root.ts";
31
- export { makeWritable, makeReadonly, isReadonly, header, stampGenerated } from "./src/generated.ts";
32
29
  export type { HeaderOpts } from "./src/generated.ts";
33
- export { create } from "./src/mixin.ts";
34
30
  export type { ConstructsMixin } from "./src/mixin.ts";
35
- export { moduleStatements } from "./src/module-exports.ts";
36
31
  export type { ModuleStatement, ModuleExport } from "./src/module-exports.ts";
37
- export { isTsoaController, generateOpenapi } from "./src/openapi.ts";
38
- export {
39
- repoRoot,
40
- DEFAULT_PACKAGE_ROOTS,
41
- projectName,
42
- toPosix,
43
- isGeneratedFile,
44
- isModuleFile,
45
- DiscoveredPackage,
46
- scanPackages,
47
- readPackageManifest,
48
- syncResynthPaths,
49
- recordedPackages,
50
- recordedRoots,
51
- } from "./src/packages.ts";
32
+ export { repoRoot, DEFAULT_PACKAGE_ROOTS, DiscoveredPackage } from "./src/packages.ts";
52
33
  export type { RecordedPackage } from "./src/packages.ts";
53
34
  export { PnpmWorkspaceState } from "./src/pnpm-workspace.ts";
54
35
  export type { Catalog, AllowBuilds, DBXToolsPNPMWorkspaceOptions } from "./src/pnpm-workspace.ts";
55
- export {
56
- PackageIdentifier,
57
- identifier,
58
- applyCompilerOptions,
59
- applyIncludes,
60
- applyTasks,
61
- applyExports,
62
- addExports,
63
- addPackageFiles,
64
- srcModuleExports,
65
- PROJEN_VERSION,
66
- DBXToolsNodeProject,
67
- DBXToolsTypeScriptProject,
68
- taskScript,
69
- applyToProjects,
70
- } from "./src/project.ts";
71
- export type {
72
- DBXToolsProject,
73
- DBXToolsProjectOptions,
74
- DBXToolsTypeScriptProjectOptions,
75
- ApplyToProjectsOptions,
76
- } from "./src/project.ts";
77
- export {
78
- isProject,
79
- isDBXToolsProject,
80
- hasName,
81
- hasIdentifierPackageName,
82
- hasIdentifierName,
83
- hasIdentifierScope,
84
- hasTag,
85
- hasPath,
86
- } from "./src/project-predicate.ts";
36
+ export { PackageIdentifier, PROJEN_VERSION, DBXToolsNodeProject, DBXToolsTypeScriptProject } from "./src/project.ts";
37
+ export type { DBXToolsProject, DBXToolsProjectOptions, DBXToolsTypeScriptProjectOptions, ApplyToProjectsOptions } from "./src/project.ts";
38
+ export { COMPILED_DIR, COMPILED_COMPILER_OPTIONS } from "./src/publish.ts";
87
39
  export { DBXToolsRelease } from "./src/release.ts";
88
40
  export type { StandaloneRelease, DBXToolsReleaseOptions } from "./src/release.ts";
89
- export { runSynth } from "./src/scaffold.ts";
90
41
  export { AGNOSTIC_COMPILER_OPTIONS, PACKAGE_TAG_MIXINS } from "./src/tags.ts";
91
42
  export type { PackageTag } from "./src/tags.ts";
92
43
  export { DBXToolsRootTsconfig } from "./src/tsconfig.ts";
93
- export { ViteConfigFile } from "./src/vite.ts";
44
+ export { DEFAULT_VITE_OVERRIDES, ViteConfigFile } from "./src/vite.ts";
94
45
  export { DBXToolsVsCode } from "./src/vscode.ts";
95
- export { watchRoots, watchLoop } from "./src/watch.ts";
96
46
  export type { IgnoreGroupOptions } from "./src/watch.ts";
package/package.json CHANGED
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "main": "index.ts",
34
34
  "license": "Apache-2.0",
35
- "version": "0.6.9",
35
+ "version": "0.6.10",
36
36
  "types": "index.ts",
37
37
  "type": "module",
38
38
  "exports": {
package/src/barrels.ts CHANGED
@@ -98,9 +98,19 @@ const BARREL_HEADER: HeaderOpts = {
98
98
  source: "the exporting modules in ./src",
99
99
  };
100
100
 
101
- /** `pnpm-workspace` -> `pnpmWorkspace`; nested paths join in camelCase. */
101
+ /** `pnpm-workspace` -> `pnpmWorkspace`; `local-fs` -> `localFS` (`fs` -> `FS`). */
102
102
  function kebabToCamel(segment: string): string {
103
- return segment.replace(/-([a-z])/g, (_, c: string) => c.toUpperCase());
103
+ const tokens = [...string.tokenizeWithOptions({ lowerCase: true, capitalize: true }, segment)];
104
+ if (tokens.length === 0) return segment;
105
+ const [first, ...rest] = tokens;
106
+ // Standalone acronym modules (`fs`, `ai`) stay lowercase so they match
107
+ // Node-style namespaces (`import * as fs`). Trailing / mid acronyms keep
108
+ // their override casing (`localFS`).
109
+ const head =
110
+ rest.length === 0 && first === first.toUpperCase()
111
+ ? first.toLowerCase()
112
+ : first.charAt(0).toLowerCase() + first.slice(1);
113
+ return head + rest.join("");
104
114
  }
105
115
 
106
116
  /** Derive a valid namespace identifier from a relocated barrel module path. */
@@ -134,9 +144,11 @@ function namespaceLines(content: string): { ns: string; modulePath: string }[] {
134
144
  /**
135
145
  * Append hoisted top-level re-exports for every export that is UNIQUE across the
136
146
  * package's modules - `export type { ... }` for types, `export { ... }` for
137
- * values. A name declared by two or more modules is ambiguous and left
138
- * namespace-only. `suppress` names (a hand-authored `exports.ts` surface) are
139
- * never hoisted so that file stays authoritative.
147
+ * non-function values (classes, consts, enums, …). `export function` names are
148
+ * never hoisted; they stay namespace-only (`posixPath.toPosix`). A name declared
149
+ * by two or more modules is ambiguous and left namespace-only. `suppress` names
150
+ * (a hand-authored `exports.ts` surface) are never hoisted so that file stays
151
+ * authoritative.
140
152
  */
141
153
  function hoistUniqueExports(content: string, pkgDir: string, suppress: Set<string>): string {
142
154
  const namespaces = namespaceLines(content);
@@ -148,14 +160,15 @@ function hoistUniqueExports(content: string, pkgDir: string, suppress: Set<strin
148
160
  const blocked = new Set<string>(suppress);
149
161
  for (const { ns } of namespaces) blocked.add(ns);
150
162
 
151
- // Uniqueness is tallied over types AND values together - name -> { count,
152
- // owning module } - so a name any two modules share stays namespace-only
153
- // whichever kind each one is. `moduleExports` already dedupes within a module,
154
- // so a count above one always means more than one module.
163
+ // Uniqueness is tallied over hoistable types AND values together - name ->
164
+ // { count, owning module }. Functions are excluded from hoisting and from
165
+ // this tally so they do not block a same-named type/class in another module.
155
166
  const seen = new Map<string, { count: number; modulePath: string }>();
156
167
  const perModule = new Map<string, ModuleExport[]>();
157
168
  for (const { modulePath } of namespaces) {
158
- const exports = moduleExports(join(pkgDir, modulePath.replace(/^\.\//, "")));
169
+ const exports = moduleExports(join(pkgDir, modulePath.replace(/^\.\//, ""))).filter(
170
+ (e) => !e.isFunction,
171
+ );
159
172
  perModule.set(modulePath, exports);
160
173
  for (const { name } of exports) {
161
174
  const prior = seen.get(name);
@@ -16,7 +16,8 @@
16
16
  * Each name carries whether it is TYPE-only (`interface` / `type` alias /
17
17
  * `export type { ... }`), so the barrel can emit `export type { ... }` for it -
18
18
  * required under `isolatedModules`, where re-exporting a type through a value
19
- * `export { ... }` is a hard error (TS1205).
19
+ * `export { ... }` is a hard error (TS1205). `export function` names are marked
20
+ * `isFunction` so the barrel leaves them namespace-only.
20
21
  */
21
22
  import { readFileSync } from "node:fs";
22
23
  import { createRequire } from "node:module";
@@ -58,11 +59,16 @@ export function moduleStatements(file: string): readonly ModuleStatement[] {
58
59
  export interface ModuleExport {
59
60
  readonly name: string;
60
61
  readonly isType: boolean;
62
+ /** `export function` / `export async function` - never hoisted to the barrel. */
63
+ readonly isFunction: boolean;
61
64
  }
62
65
 
63
66
  /** Declaration node types that are inherently type-only. */
64
67
  const TYPE_DECLARATIONS = new Set(["TSInterfaceDeclaration", "TSTypeAliasDeclaration"]);
65
68
 
69
+ /** Declaration node types that are functions (not hoisted). */
70
+ const FUNCTION_DECLARATIONS = new Set(["FunctionDeclaration", "TSDeclareFunction"]);
71
+
66
72
  /**
67
73
  * Parse `file` and return its own top-level named exports (see the module
68
74
  * docstring for what's included). Returns `[]` on a read/parse error - a
@@ -102,18 +108,26 @@ export function moduleExports(file: string): ModuleExport[] {
102
108
  const decl = node.declaration;
103
109
  if (decl) {
104
110
  if (decl.id?.name) {
105
- push({ name: decl.id.name, isType: stmtIsType || TYPE_DECLARATIONS.has(decl.type) });
111
+ push({
112
+ name: decl.id.name,
113
+ isType: stmtIsType || TYPE_DECLARATIONS.has(decl.type),
114
+ isFunction: FUNCTION_DECLARATIONS.has(decl.type),
115
+ });
106
116
  }
107
117
  for (const d of decl.declarations ?? []) {
108
118
  if (d.id?.type === "Identifier" && d.id.name) {
109
- push({ name: d.id.name, isType: stmtIsType });
119
+ push({ name: d.id.name, isType: stmtIsType, isFunction: false });
110
120
  }
111
121
  }
112
122
  }
113
123
  for (const spec of node.specifiers ?? []) {
114
124
  const name = spec.exported?.name ?? spec.exported?.value;
115
125
  if (!name) continue;
116
- push({ name, isType: stmtIsType || spec.exportKind === "type" });
126
+ push({
127
+ name,
128
+ isType: stmtIsType || spec.exportKind === "type",
129
+ isFunction: false,
130
+ });
117
131
  }
118
132
  }
119
133
  return [...byName.values()];