@fnd-platform/core 1.0.0-alpha.1

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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +166 -0
  3. package/lib/components/index.d.ts +22 -0
  4. package/lib/components/index.d.ts.map +1 -0
  5. package/lib/components/index.js +25 -0
  6. package/lib/components/index.js.map +1 -0
  7. package/lib/components/nx-config.d.ts +67 -0
  8. package/lib/components/nx-config.d.ts.map +1 -0
  9. package/lib/components/nx-config.js +102 -0
  10. package/lib/components/nx-config.js.map +1 -0
  11. package/lib/components/pnpm-workspace.d.ts +34 -0
  12. package/lib/components/pnpm-workspace.d.ts.map +1 -0
  13. package/lib/components/pnpm-workspace.js +34 -0
  14. package/lib/components/pnpm-workspace.js.map +1 -0
  15. package/lib/components/shared-eslint.d.ts +51 -0
  16. package/lib/components/shared-eslint.d.ts.map +1 -0
  17. package/lib/components/shared-eslint.js +72 -0
  18. package/lib/components/shared-eslint.js.map +1 -0
  19. package/lib/components/shared-prettier.d.ts +66 -0
  20. package/lib/components/shared-prettier.d.ts.map +1 -0
  21. package/lib/components/shared-prettier.js +36 -0
  22. package/lib/components/shared-prettier.js.map +1 -0
  23. package/lib/components/shared-typescript.d.ts +71 -0
  24. package/lib/components/shared-typescript.d.ts.map +1 -0
  25. package/lib/components/shared-typescript.js +51 -0
  26. package/lib/components/shared-typescript.js.map +1 -0
  27. package/lib/components/shared-vitest.d.ts +85 -0
  28. package/lib/components/shared-vitest.d.ts.map +1 -0
  29. package/lib/components/shared-vitest.js +76 -0
  30. package/lib/components/shared-vitest.js.map +1 -0
  31. package/lib/index.d.ts +14 -0
  32. package/lib/index.d.ts.map +1 -0
  33. package/lib/index.js +24 -0
  34. package/lib/index.js.map +1 -0
  35. package/lib/monorepo-project.d.ts +81 -0
  36. package/lib/monorepo-project.d.ts.map +1 -0
  37. package/lib/monorepo-project.js +151 -0
  38. package/lib/monorepo-project.js.map +1 -0
  39. package/lib/options.d.ts +92 -0
  40. package/lib/options.d.ts.map +1 -0
  41. package/lib/options.js +3 -0
  42. package/lib/options.js.map +1 -0
  43. package/package.json +49 -0
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FndMonorepoProject = void 0;
4
+ const projen_1 = require("projen");
5
+ const javascript_1 = require("projen/lib/javascript");
6
+ const components_1 = require("./components");
7
+ /**
8
+ * Creates a new fnd-platform monorepo project.
9
+ *
10
+ * This class extends Projen's TypeScriptProject to provide a complete
11
+ * monorepo setup with:
12
+ * - pnpm workspace configuration
13
+ * - NX build orchestration with intelligent caching
14
+ * - Shared TypeScript, ESLint, Prettier, and Vitest configurations
15
+ * - Standard scripts for building, testing, and linting
16
+ *
17
+ * All configuration files are generated automatically during synthesis.
18
+ * Users should not edit generated files directly - instead, modify the
19
+ * project configuration in `.projenrc.ts` and run synthesis.
20
+ *
21
+ * @example
22
+ * Basic usage:
23
+ * ```typescript
24
+ * import { FndMonorepoProject } from '@fnd-platform/core';
25
+ *
26
+ * const project = new FndMonorepoProject({
27
+ * name: 'my-app',
28
+ * defaultReleaseBranch: 'main',
29
+ * });
30
+ *
31
+ * project.synth();
32
+ * ```
33
+ *
34
+ * @example
35
+ * With custom workspace packages:
36
+ * ```typescript
37
+ * const project = new FndMonorepoProject({
38
+ * name: 'my-app',
39
+ * defaultReleaseBranch: 'main',
40
+ * workspacePackages: ['packages/*', 'apps/*'],
41
+ * nxCache: true,
42
+ * });
43
+ *
44
+ * project.synth();
45
+ * ```
46
+ */
47
+ class FndMonorepoProject extends projen_1.typescript.TypeScriptProject {
48
+ /**
49
+ * The pnpm workspace configuration component.
50
+ */
51
+ pnpmWorkspace;
52
+ /**
53
+ * The NX configuration component.
54
+ */
55
+ nxConfig;
56
+ /**
57
+ * The shared TypeScript configuration component.
58
+ */
59
+ sharedTypeScript;
60
+ /**
61
+ * The shared ESLint configuration component.
62
+ */
63
+ sharedEslint;
64
+ /**
65
+ * The shared Prettier configuration component.
66
+ */
67
+ sharedPrettier;
68
+ /**
69
+ * The shared Vitest configuration component.
70
+ */
71
+ sharedVitest;
72
+ /**
73
+ * Creates a new FndMonorepoProject.
74
+ *
75
+ * @param options - Configuration options for the monorepo
76
+ * @throws {Error} If required options (name, defaultReleaseBranch) are missing
77
+ */
78
+ constructor(options) {
79
+ // Validate required options
80
+ if (!options.name) {
81
+ throw new Error('FndMonorepoProject requires a name option');
82
+ }
83
+ if (!options.defaultReleaseBranch) {
84
+ throw new Error('FndMonorepoProject requires a defaultReleaseBranch option');
85
+ }
86
+ // Call super with merged options
87
+ super({
88
+ ...options,
89
+ packageManager: options.packageManager ?? javascript_1.NodePackageManager.PNPM,
90
+ // Disable projen's default features that we'll override
91
+ sampleCode: false,
92
+ jest: false,
93
+ eslint: false,
94
+ prettier: false,
95
+ // Set projenrc config
96
+ projenrcTs: true,
97
+ });
98
+ // Initialize components
99
+ // 1. pnpm workspace configuration
100
+ this.pnpmWorkspace = new components_1.PnpmWorkspace(this, {
101
+ packages: options.workspacePackages ?? ['packages/*'],
102
+ });
103
+ // 2. NX configuration for build orchestration
104
+ this.nxConfig = new components_1.NxConfig(this, {
105
+ cacheEnabled: options.nxCache ?? true,
106
+ cacheableOperations: options.nxCacheableOperations ?? ['build', 'test', 'lint'],
107
+ targetDefaults: options.nxTargetDefaults,
108
+ });
109
+ // 3. Shared TypeScript configuration
110
+ this.sharedTypeScript = new components_1.SharedTypeScript(this);
111
+ // 4. Shared ESLint configuration
112
+ this.sharedEslint = new components_1.SharedEslint(this);
113
+ // 5. Shared Prettier configuration
114
+ this.sharedPrettier = new components_1.SharedPrettier(this);
115
+ // 6. Shared Vitest configuration
116
+ this.sharedVitest = new components_1.SharedVitest(this);
117
+ // Add monorepo-specific scripts to package.json
118
+ // These override the default projen scripts for monorepo usage
119
+ this.package.setScript('build', 'nx run-many --target=build --all');
120
+ this.package.setScript('test', 'nx run-many --target=test --all');
121
+ this.package.setScript('test:coverage', 'nx run-many --target=test --all --coverage');
122
+ this.package.setScript('lint', 'nx run-many --target=lint --all');
123
+ this.package.setScript('format', 'prettier --write "**/*.{ts,tsx,js,jsx,json,md,yaml,yml}"');
124
+ this.package.setScript('format:check', 'prettier --check "**/*.{ts,tsx,js,jsx,json,md,yaml,yml}"');
125
+ // Add devDependencies for the monorepo
126
+ this.addDevDeps('nx@19.8.4', 'typescript@^5.6.3', 'eslint@^8.57.0', '@typescript-eslint/eslint-plugin@^7.18.0', '@typescript-eslint/parser@^7.18.0', 'prettier@^3.3.3', 'vitest@^1.6.0', '@vitest/coverage-v8@^1.6.0', 'tsx@^4.19.2');
127
+ // Set package manager version in package.json
128
+ this.package.addField('packageManager', 'pnpm@10.6.5');
129
+ // Set engines
130
+ this.package.addField('engines', {
131
+ node: '>=20.0.0',
132
+ pnpm: '>=8.0.0',
133
+ });
134
+ // Create empty packages directory
135
+ new projen_1.TextFile(this, 'packages/.gitkeep', {
136
+ lines: [''],
137
+ });
138
+ // Create .gitignore with standard ignores
139
+ this.addGitIgnorePatterns();
140
+ }
141
+ /**
142
+ * Adds standard gitignore patterns for the monorepo.
143
+ */
144
+ addGitIgnorePatterns() {
145
+ // The parent class already creates a .gitignore via IgnoreFile
146
+ // We just need to add our patterns to it
147
+ this.gitignore.addPatterns('# Dependencies', 'node_modules/', '', '# Build outputs', 'dist/', 'lib/', '*.js.map', '*.d.ts.map', '', '# NX', '.nx/', '', '# Coverage', 'coverage/', '', '# IDE', '.idea/', '.vscode/', '*.swp', '*.swo', '', '# OS', '.DS_Store', 'Thumbs.db', '', '# Logs', '*.log', 'npm-debug.log*', '', '# Misc', '.env', '.env.local', '*.tgz');
148
+ }
149
+ }
150
+ exports.FndMonorepoProject = FndMonorepoProject;
151
+ //# sourceMappingURL=monorepo-project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monorepo-project.js","sourceRoot":"","sources":["../src/monorepo-project.ts"],"names":[],"mappings":";;;AAAA,mCAA8C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AAC,SAAS,EAAE;YAC/B,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,SAAS;SAChB,CAAC,CAAC;QAEH,kCAAkC;QAClC,IAAI,iBAAQ,CAAC,IAAI,EAAE,mBAAmB,EAAE;YACtC,KAAK,EAAE,CAAC,EAAE,CAAC;SACZ,CAAC,CAAC;QAEH,0CAA0C;QAC1C,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;IAED;;OAEG;IACK,oBAAoB;QAC1B,+DAA+D;QAC/D,yCAAyC;QACzC,IAAI,CAAC,SAAS,CAAC,WAAW,CACxB,gBAAgB,EAChB,eAAe,EACf,EAAE,EACF,iBAAiB,EACjB,OAAO,EACP,MAAM,EACN,UAAU,EACV,YAAY,EACZ,EAAE,EACF,MAAM,EACN,MAAM,EACN,EAAE,EACF,YAAY,EACZ,WAAW,EACX,EAAE,EACF,OAAO,EACP,QAAQ,EACR,UAAU,EACV,OAAO,EACP,OAAO,EACP,EAAE,EACF,MAAM,EACN,WAAW,EACX,WAAW,EACX,EAAE,EACF,QAAQ,EACR,OAAO,EACP,gBAAgB,EAChB,EAAE,EACF,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,OAAO,CACR,CAAC;IACJ,CAAC;CACF;AA1KD,gDA0KC"}
@@ -0,0 +1,92 @@
1
+ import { typescript } from 'projen';
2
+ /**
3
+ * Configuration for an NX target (build, test, lint, etc.).
4
+ */
5
+ export interface NxTargetConfig {
6
+ /**
7
+ * Dependencies that must run before this target.
8
+ * Use `^build` to depend on the build target of all dependencies.
9
+ *
10
+ * @example ['^build']
11
+ */
12
+ readonly dependsOn?: string[];
13
+ /**
14
+ * Whether this target's output should be cached.
15
+ *
16
+ * @default true
17
+ */
18
+ readonly cache?: boolean;
19
+ /**
20
+ * Input files that affect this target's cache.
21
+ *
22
+ * @example ['default', '^production']
23
+ */
24
+ readonly inputs?: string[];
25
+ /**
26
+ * Output files produced by this target.
27
+ *
28
+ * @example ['{projectRoot}/dist']
29
+ */
30
+ readonly outputs?: string[];
31
+ }
32
+ /**
33
+ * Configuration options for FndMonorepoProject.
34
+ *
35
+ * Extends Projen's TypeScriptProjectOptions with monorepo-specific settings
36
+ * for pnpm workspaces and NX orchestration.
37
+ *
38
+ * @example
39
+ * Basic usage:
40
+ * ```typescript
41
+ * const project = new FndMonorepoProject({
42
+ * name: 'my-app',
43
+ * defaultReleaseBranch: 'main',
44
+ * });
45
+ * ```
46
+ *
47
+ * @example
48
+ * With custom workspace packages:
49
+ * ```typescript
50
+ * const project = new FndMonorepoProject({
51
+ * name: 'my-app',
52
+ * defaultReleaseBranch: 'main',
53
+ * workspacePackages: ['packages/*', 'apps/*', 'tools/*'],
54
+ * nxCache: true,
55
+ * });
56
+ * ```
57
+ */
58
+ export interface FndMonorepoProjectOptions extends typescript.TypeScriptProjectOptions {
59
+ /**
60
+ * Enable NX caching for build tasks.
61
+ *
62
+ * When enabled, NX will cache the results of build, test, and lint
63
+ * operations to speed up subsequent runs.
64
+ *
65
+ * @default true
66
+ */
67
+ readonly nxCache?: boolean;
68
+ /**
69
+ * Workspace package directory patterns.
70
+ *
71
+ * Glob patterns defining where workspace packages are located.
72
+ * These patterns are used in pnpm-workspace.yaml.
73
+ *
74
+ * @default ['packages/*']
75
+ * @example ['packages/*', 'apps/*', 'tools/*']
76
+ */
77
+ readonly workspacePackages?: string[];
78
+ /**
79
+ * Custom NX target defaults.
80
+ *
81
+ * Override or extend the default NX target configurations
82
+ * for build, test, and lint operations.
83
+ */
84
+ readonly nxTargetDefaults?: Record<string, NxTargetConfig>;
85
+ /**
86
+ * Operations that should be cached by NX.
87
+ *
88
+ * @default ['build', 'test', 'lint']
89
+ */
90
+ readonly nxCacheableOperations?: string[];
91
+ }
92
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAE9B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAEzB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAE3B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,yBAA0B,SAAQ,UAAU,CAAC,wBAAwB;IACpF;;;;;;;OAOG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;;;;;OAQG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAEtC;;;;;OAKG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAE3D;;;;OAIG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3C"}
package/lib/options.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@fnd-platform/core",
3
+ "version": "1.0.0-alpha.1",
4
+ "description": "Core Projen project classes for fnd-platform monorepo scaffolding",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "files": [
8
+ "lib/"
9
+ ],
10
+ "dependencies": {
11
+ "projen": "^0.91.0"
12
+ },
13
+ "peerDependencies": {
14
+ "projen": "^0.91.0"
15
+ },
16
+ "devDependencies": {
17
+ "@types/node": "^20.0.0",
18
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
19
+ "@typescript-eslint/parser": "^7.18.0",
20
+ "@vitest/coverage-v8": "^1.6.0",
21
+ "eslint": "^8.57.0",
22
+ "typescript": "^5.6.3",
23
+ "vitest": "^1.6.0"
24
+ },
25
+ "keywords": [
26
+ "projen",
27
+ "monorepo",
28
+ "aws",
29
+ "typescript",
30
+ "scaffolding",
31
+ "cdk"
32
+ ],
33
+ "license": "MIT",
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/your-org/fnd-platform",
40
+ "directory": "packages/core"
41
+ },
42
+ "scripts": {
43
+ "build": "tsc",
44
+ "test": "vitest run",
45
+ "test:watch": "vitest",
46
+ "test:coverage": "vitest run --coverage",
47
+ "lint": "eslint src/ test/"
48
+ }
49
+ }