pastoria 1.0.14 → 1.1.0
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/build.js +1 -1
- package/dist/build.js.map +1 -1
- package/dist/build_command.d.ts +2 -0
- package/dist/build_command.d.ts.map +1 -0
- package/dist/build_command.js +13 -0
- package/dist/build_command.js.map +1 -0
- package/dist/gen.d.ts +2 -0
- package/dist/gen.d.ts.map +1 -0
- package/dist/gen.js +19 -0
- package/dist/gen.js.map +1 -0
- package/dist/index.js +45 -9
- package/dist/index.js.map +1 -1
- package/justfile +41 -0
- package/package.json +6 -1
- package/CHANGELOG.md +0 -92
- package/src/build.ts +0 -306
- package/src/devserver.ts +0 -58
- package/src/generate.ts +0 -918
- package/src/index.ts +0 -40
- package/src/logger.ts +0 -12
- package/src/vite_plugin.ts +0 -109
- package/tsconfig.json +0 -21
package/dist/build.js
CHANGED
|
@@ -45,7 +45,7 @@ async function runGratsCompiler() {
|
|
|
45
45
|
}
|
|
46
46
|
async function runRelayCompiler() {
|
|
47
47
|
const relayPath = path.join(process.cwd(), 'node_modules', '.bin', 'relay-compiler');
|
|
48
|
-
await runCommand(relayPath, []);
|
|
48
|
+
await runCommand(relayPath, ['--repersist']);
|
|
49
49
|
}
|
|
50
50
|
function fileMatchesPastoriaTags(filePath, content) {
|
|
51
51
|
// Skip generated files
|
package/dist/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,EAAE,EAAC,cAAc,EAAE,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAClD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,eAAe,EAAE,OAAO,EAA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AC,CACF,CAAC;QAEF,2BAA2B;QAC3B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;YAC9B,MAAM,YAAY,CAAC,WAAW,EAAE,CAAC;YACjC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_command.d.ts","sourceRoot":"","sources":["../src/build_command.ts"],"names":[],"mappings":"AAIA,wBAAsB,YAAY,CAAC,MAAM,EAAE,QAAQ,GAAG,QAAQ,iBAW7D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { build } from 'vite';
|
|
2
|
+
import { logInfo } from './logger.js';
|
|
3
|
+
import { CLIENT_BUILD, createBuildConfig, SERVER_BUILD } from './vite_plugin.js';
|
|
4
|
+
export async function runViteBuild(target) {
|
|
5
|
+
const buildType = target === 'client' ? CLIENT_BUILD : SERVER_BUILD;
|
|
6
|
+
logInfo(`Building ${target}...`);
|
|
7
|
+
await build({
|
|
8
|
+
...createBuildConfig(buildType),
|
|
9
|
+
configFile: false,
|
|
10
|
+
});
|
|
11
|
+
logInfo(`${target} build complete!`);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=build_command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_command.js","sourceRoot":"","sources":["../src/build_command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAC,OAAO,EAAC,MAAM,aAAa,CAAC;AACpC,OAAO,EAAC,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE/E,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAA2B;IAC5D,MAAM,SAAS,GAAG,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC;IAEpE,OAAO,CAAC,YAAY,MAAM,KAAK,CAAC,CAAC;IAEjC,MAAM,KAAK,CAAC;QACV,GAAG,iBAAiB,CAAC,SAAS,CAAC;QAC/B,UAAU,EAAE,KAAK;KAClB,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,MAAM,kBAAkB,CAAC,CAAC;AACvC,CAAC"}
|
package/dist/gen.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gen.d.ts","sourceRoot":"","sources":["../src/gen.ts"],"names":[],"mappings":"AAQA,wBAAsB,iBAAiB,kBAiBtC"}
|
package/dist/gen.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { IndentationText, Project } from 'ts-morph';
|
|
3
|
+
import { generatePastoriaArtifacts, generatePastoriaExports, } from './generate.js';
|
|
4
|
+
import { logInfo } from './logger.js';
|
|
5
|
+
export async function runCodeGeneration() {
|
|
6
|
+
const project = new Project({
|
|
7
|
+
tsConfigFilePath: path.join(process.cwd(), 'tsconfig.json'),
|
|
8
|
+
manipulationSettings: {
|
|
9
|
+
indentationText: IndentationText.TwoSpaces,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
logInfo('Generating Pastoria artifacts...');
|
|
13
|
+
// Generate exports and collect metadata
|
|
14
|
+
const metadata = await generatePastoriaExports(project);
|
|
15
|
+
// Generate artifacts using cached metadata
|
|
16
|
+
await generatePastoriaArtifacts(project, metadata);
|
|
17
|
+
logInfo('Code generation complete!');
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=gen.js.map
|
package/dist/gen.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gen.js","sourceRoot":"","sources":["../src/gen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,eAAe,EAAE,OAAO,EAAC,MAAM,UAAU,CAAC;AAClD,OAAO,EACL,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,OAAO,EAAC,MAAM,aAAa,CAAC;AAEpC,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC;QAC1B,gBAAgB,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,eAAe,CAAC;QAC3D,oBAAoB,EAAE;YACpB,eAAe,EAAE,eAAe,CAAC,SAAS;SAC3C;KACF,CAAC,CAAC;IAEH,OAAO,CAAC,kCAAkC,CAAC,CAAC;IAE5C,wCAAwC;IACxC,MAAM,QAAQ,GAAG,MAAM,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAExD,2CAA2C;IAC3C,MAAM,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAEnD,OAAO,CAAC,2BAA2B,CAAC,CAAC;AACvC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,35 @@
|
|
|
2
2
|
import { program } from 'commander';
|
|
3
3
|
import { readFile } from 'node:fs/promises';
|
|
4
4
|
import * as path from 'node:path';
|
|
5
|
-
import {
|
|
5
|
+
import { IndentationText, Project } from 'ts-morph';
|
|
6
|
+
import { build } from 'vite';
|
|
6
7
|
import { startDevserver } from './devserver.js';
|
|
8
|
+
import { generatePastoriaArtifacts, generatePastoriaExports, } from './generate.js';
|
|
9
|
+
import { logInfo } from './logger.js';
|
|
10
|
+
import { CLIENT_BUILD, createBuildConfig, SERVER_BUILD } from './vite_plugin.js';
|
|
11
|
+
async function runCodeGeneration() {
|
|
12
|
+
const project = new Project({
|
|
13
|
+
tsConfigFilePath: path.join(process.cwd(), 'tsconfig.json'),
|
|
14
|
+
manipulationSettings: {
|
|
15
|
+
indentationText: IndentationText.TwoSpaces,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
logInfo('Generating Pastoria artifacts...');
|
|
19
|
+
// Generate exports and collect metadata
|
|
20
|
+
const metadata = await generatePastoriaExports(project);
|
|
21
|
+
// Generate artifacts using cached metadata
|
|
22
|
+
await generatePastoriaArtifacts(project, metadata);
|
|
23
|
+
logInfo('Code generation complete!');
|
|
24
|
+
}
|
|
25
|
+
async function runViteBuild(target) {
|
|
26
|
+
const buildType = target === 'client' ? CLIENT_BUILD : SERVER_BUILD;
|
|
27
|
+
logInfo(`Building ${target}...`);
|
|
28
|
+
await build({
|
|
29
|
+
...createBuildConfig(buildType),
|
|
30
|
+
configFile: false,
|
|
31
|
+
});
|
|
32
|
+
logInfo(`${target} build complete!`);
|
|
33
|
+
}
|
|
7
34
|
async function main() {
|
|
8
35
|
const packageData = JSON.parse(await readFile(path.join(import.meta.dirname, '../package.json'), 'utf-8'));
|
|
9
36
|
program
|
|
@@ -12,17 +39,26 @@ async function main() {
|
|
|
12
39
|
.version(packageData.version);
|
|
13
40
|
program
|
|
14
41
|
.command('dev')
|
|
15
|
-
.description('Start the pastoria
|
|
42
|
+
.description('Start the pastoria development server')
|
|
16
43
|
.option('--port <port>', 'Port the devserver will listen on', '3000')
|
|
17
44
|
.action(startDevserver);
|
|
18
45
|
program
|
|
19
|
-
.command('
|
|
20
|
-
.description('
|
|
21
|
-
.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
.
|
|
46
|
+
.command('gen')
|
|
47
|
+
.description('Generate Pastoria router artifacts')
|
|
48
|
+
.action(async () => {
|
|
49
|
+
await runCodeGeneration();
|
|
50
|
+
});
|
|
51
|
+
program
|
|
52
|
+
.command('build')
|
|
53
|
+
.description('Build for production')
|
|
54
|
+
.argument('<target>', 'Build target: client or server')
|
|
55
|
+
.action(async (target) => {
|
|
56
|
+
if (target !== 'client' && target !== 'server') {
|
|
57
|
+
console.error('Invalid target. Must be "client" or "server"');
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
await runViteBuild(target);
|
|
61
|
+
});
|
|
26
62
|
program.parseAsync();
|
|
27
63
|
}
|
|
28
64
|
main().catch(console.error);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,eAAe,EAAE,OAAO,EAAC,MAAM,UAAU,CAAC;AAClD,OAAO,EAAC,KAAK,EAAC,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACL,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,OAAO,EAAC,MAAM,aAAa,CAAC;AACpC,OAAO,EAAC,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE/E,KAAK,UAAU,iBAAiB;IAC9B,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC;QAC1B,gBAAgB,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,eAAe,CAAC;QAC3D,oBAAoB,EAAE;YACpB,eAAe,EAAE,eAAe,CAAC,SAAS;SAC3C;KACF,CAAC,CAAC;IAEH,OAAO,CAAC,kCAAkC,CAAC,CAAC;IAE5C,wCAAwC;IACxC,MAAM,QAAQ,GAAG,MAAM,uBAAuB,CAAC,OAAO,CAAC,CAA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CAAC,UAAU,EAAE,gCAAgC,CAAC;SACtD,MAAM,CAAC,KAAK,EAAE,MAAc,EAAE,EAAE;QAC/B,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/C,OAAO,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;YAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,MAAM,YAAY,CAAC,MAA6B,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEL,OAAO,CAAC,UAAU,EAAE,CAAC;AACvB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|
package/justfile
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Generate schema, relay, and router code.
|
|
2
|
+
[no-cd]
|
|
3
|
+
default: router
|
|
4
|
+
|
|
5
|
+
# Generate GraphQL schema using Grats
|
|
6
|
+
[no-cd]
|
|
7
|
+
[private]
|
|
8
|
+
grats:
|
|
9
|
+
pnpm exec grats
|
|
10
|
+
|
|
11
|
+
# Compile Relay queries with persisted queries
|
|
12
|
+
[no-cd]
|
|
13
|
+
[private]
|
|
14
|
+
relay: grats
|
|
15
|
+
pnpm exec relay-compiler --repersist
|
|
16
|
+
|
|
17
|
+
# Generate Pastoria router artifacts (app_root, context, router, resources, handlers)
|
|
18
|
+
[no-cd]
|
|
19
|
+
[private]
|
|
20
|
+
router: relay
|
|
21
|
+
pnpm exec pastoria gen
|
|
22
|
+
|
|
23
|
+
# Build client bundle
|
|
24
|
+
[no-cd]
|
|
25
|
+
_client: router
|
|
26
|
+
pnpm exec pastoria build client
|
|
27
|
+
|
|
28
|
+
# Build server bundle
|
|
29
|
+
[no-cd]
|
|
30
|
+
_server: router
|
|
31
|
+
pnpm exec pastoria build server
|
|
32
|
+
|
|
33
|
+
# Build both client and server for production
|
|
34
|
+
[no-cd]
|
|
35
|
+
[parallel]
|
|
36
|
+
release: _client _server
|
|
37
|
+
|
|
38
|
+
# Start development server
|
|
39
|
+
[no-cd]
|
|
40
|
+
dev:
|
|
41
|
+
pnpm exec pastoria dev
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pastoria",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Pastoria Development CLI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
"bin": {
|
|
10
10
|
"pastoria": "./dist/index.js"
|
|
11
11
|
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"templates",
|
|
15
|
+
"justfile"
|
|
16
|
+
],
|
|
12
17
|
"dependencies": {
|
|
13
18
|
"@parcel/watcher": "^2.5.1",
|
|
14
19
|
"@tailwindcss/vite": "^4.1.15",
|
package/CHANGELOG.md
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
# pastoria
|
|
2
|
-
|
|
3
|
-
## 1.0.14
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- a38076a: Trim down variables passed to entrypoints to only those needed
|
|
8
|
-
|
|
9
|
-
## 1.0.13
|
|
10
|
-
|
|
11
|
-
### Patch Changes
|
|
12
|
-
|
|
13
|
-
- 0ef0bdc: Automatically infer variable names and types from queries on
|
|
14
|
-
resource-routes if none provided
|
|
15
|
-
|
|
16
|
-
## 1.0.12
|
|
17
|
-
|
|
18
|
-
### Patch Changes
|
|
19
|
-
|
|
20
|
-
- 641b356: Add pastoria make command
|
|
21
|
-
|
|
22
|
-
## 1.0.11
|
|
23
|
-
|
|
24
|
-
### Patch Changes
|
|
25
|
-
|
|
26
|
-
- b139f3c: Bump patch versions
|
|
27
|
-
- Updated dependencies [b139f3c]
|
|
28
|
-
- pastoria-config@1.0.1
|
|
29
|
-
|
|
30
|
-
## 1.0.10
|
|
31
|
-
|
|
32
|
-
### Patch Changes
|
|
33
|
-
|
|
34
|
-
- 1ae49d3: Update router generator to automatically create an entrypoint and
|
|
35
|
-
resource
|
|
36
|
-
- 4ed4588: Don't duplicate JSResource import when generating code
|
|
37
|
-
- e7e5519: Detect queries and entrypoints from type annotations
|
|
38
|
-
|
|
39
|
-
## 1.0.9
|
|
40
|
-
|
|
41
|
-
### Patch Changes
|
|
42
|
-
|
|
43
|
-
- 60ab948: Add support for routing shorthands
|
|
44
|
-
- 37afd6c: Add support for @serverRoute
|
|
45
|
-
|
|
46
|
-
## 1.0.8
|
|
47
|
-
|
|
48
|
-
### Patch Changes
|
|
49
|
-
|
|
50
|
-
- 265903c: Add babel-plugin-relay dependency
|
|
51
|
-
|
|
52
|
-
## 1.0.7
|
|
53
|
-
|
|
54
|
-
### Patch Changes
|
|
55
|
-
|
|
56
|
-
- Move generated persisted queries output
|
|
57
|
-
|
|
58
|
-
## 1.0.6
|
|
59
|
-
|
|
60
|
-
### Patch Changes
|
|
61
|
-
|
|
62
|
-
- d81851d: Added a custom GraphQL server to remove the Yoga dependency
|
|
63
|
-
|
|
64
|
-
## 1.0.5
|
|
65
|
-
|
|
66
|
-
### Patch Changes
|
|
67
|
-
|
|
68
|
-
- Add pastoria-runtime to `noExternal`
|
|
69
|
-
|
|
70
|
-
## 1.0.4
|
|
71
|
-
|
|
72
|
-
### Patch Changes
|
|
73
|
-
|
|
74
|
-
- Update tsconfig to target nodenext modules
|
|
75
|
-
|
|
76
|
-
## 1.0.3
|
|
77
|
-
|
|
78
|
-
### Patch Changes
|
|
79
|
-
|
|
80
|
-
- Fix package.json bin config
|
|
81
|
-
|
|
82
|
-
## 1.0.2
|
|
83
|
-
|
|
84
|
-
### Patch Changes
|
|
85
|
-
|
|
86
|
-
- Remove usage of experimentalStripTypes
|
|
87
|
-
|
|
88
|
-
## 1.0.1
|
|
89
|
-
|
|
90
|
-
### Patch Changes
|
|
91
|
-
|
|
92
|
-
- Pastoria alpha version for testing
|
package/src/build.ts
DELETED
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
import ParcelWatcher, {getEventsSince, writeSnapshot} from '@parcel/watcher';
|
|
2
|
-
import {spawn} from 'node:child_process';
|
|
3
|
-
import {access, readFile} from 'node:fs/promises';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import {IndentationText, Project} from 'ts-morph';
|
|
6
|
-
import {build} from 'vite';
|
|
7
|
-
import {
|
|
8
|
-
generatePastoriaArtifacts,
|
|
9
|
-
generatePastoriaExports,
|
|
10
|
-
PASTORIA_TAG_REGEX,
|
|
11
|
-
PastoriaMetadata,
|
|
12
|
-
} from './generate.js';
|
|
13
|
-
import {logger, logInfo} from './logger.js';
|
|
14
|
-
import {CLIENT_BUILD, createBuildConfig, SERVER_BUILD} from './vite_plugin.js';
|
|
15
|
-
|
|
16
|
-
enum PastoriaMakePhase {
|
|
17
|
-
PASTORIA_EXPORTS,
|
|
18
|
-
PASTORIA_ARTIFACTS,
|
|
19
|
-
RELAY,
|
|
20
|
-
GRATS,
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const ALL_MAKE_PHASES = new Set([
|
|
24
|
-
PastoriaMakePhase.PASTORIA_EXPORTS,
|
|
25
|
-
PastoriaMakePhase.PASTORIA_ARTIFACTS,
|
|
26
|
-
PastoriaMakePhase.RELAY,
|
|
27
|
-
PastoriaMakePhase.GRATS,
|
|
28
|
-
]);
|
|
29
|
-
|
|
30
|
-
const SNAPSHOT_PATH = '.pastoriainfo';
|
|
31
|
-
|
|
32
|
-
async function runCommand(command: string, args: string[]): Promise<void> {
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
const child = spawn(command, args, {
|
|
35
|
-
cwd: process.cwd(),
|
|
36
|
-
stdio: 'inherit', // Stream output to terminal
|
|
37
|
-
shell: true,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
child.on('exit', (code) => {
|
|
41
|
-
if (code === 0) {
|
|
42
|
-
resolve();
|
|
43
|
-
} else {
|
|
44
|
-
reject(new Error(`Command failed with exit code ${code}`));
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
child.on('error', reject);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async function runGratsCompiler(): Promise<void> {
|
|
53
|
-
const gratsPath = path.join(process.cwd(), 'node_modules', '.bin', 'grats');
|
|
54
|
-
await runCommand(gratsPath, []);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async function runRelayCompiler(): Promise<void> {
|
|
58
|
-
const relayPath = path.join(
|
|
59
|
-
process.cwd(),
|
|
60
|
-
'node_modules',
|
|
61
|
-
'.bin',
|
|
62
|
-
'relay-compiler',
|
|
63
|
-
);
|
|
64
|
-
await runCommand(relayPath, []);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function fileMatchesPastoriaTags(filePath: string, content: string): boolean {
|
|
68
|
-
// Skip generated files
|
|
69
|
-
if (filePath.includes('__generated__')) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
return PASTORIA_TAG_REGEX.test(content);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function fileMatchesGratsTags(filePath: string, content: string): boolean {
|
|
76
|
-
// Skip generated files
|
|
77
|
-
if (filePath.includes('__generated__')) {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
// Match any Grats JSDoc tag
|
|
81
|
-
return /@gql\w+/.test(content);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function fileMatchesRelayImports(filePath: string, content: string): boolean {
|
|
85
|
-
// Skip generated files
|
|
86
|
-
if (filePath.includes('__generated__')) {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
return (
|
|
90
|
-
/import\s+.*\s+from\s+['"]react-relay['"]/.test(content) ||
|
|
91
|
-
/import\s+.*\s+from\s+['"]relay-runtime['"]/.test(content)
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
async function requiredMakePhasesForChanges(
|
|
96
|
-
events: Array<{type: string; path: string}>,
|
|
97
|
-
): Promise<Set<PastoriaMakePhase>> {
|
|
98
|
-
let makePhases = new Set<PastoriaMakePhase>();
|
|
99
|
-
|
|
100
|
-
await Promise.all(
|
|
101
|
-
events.map(async (event) => {
|
|
102
|
-
const filePath = event.path;
|
|
103
|
-
|
|
104
|
-
// Skip non-TypeScript/TSX files
|
|
105
|
-
if (!filePath.match(/\.(ts|tsx)$/)) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// For delete events, we can't read content, so assume it might affect all pipelines
|
|
110
|
-
if (event.type === 'delete') {
|
|
111
|
-
makePhases = ALL_MAKE_PHASES;
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Read file content for create/update events
|
|
116
|
-
try {
|
|
117
|
-
const content = await readFile(filePath, 'utf-8');
|
|
118
|
-
|
|
119
|
-
if (fileMatchesPastoriaTags(filePath, content)) {
|
|
120
|
-
makePhases.add(PastoriaMakePhase.PASTORIA_EXPORTS);
|
|
121
|
-
makePhases.add(PastoriaMakePhase.PASTORIA_ARTIFACTS);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (fileMatchesGratsTags(filePath, content)) {
|
|
125
|
-
makePhases.add(PastoriaMakePhase.GRATS);
|
|
126
|
-
makePhases.add(PastoriaMakePhase.RELAY); // Relay depends on Grats schema
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (fileMatchesRelayImports(filePath, content)) {
|
|
130
|
-
makePhases.add(PastoriaMakePhase.RELAY);
|
|
131
|
-
}
|
|
132
|
-
} catch {
|
|
133
|
-
// If we can't read the file, assume it might affect all pipelines
|
|
134
|
-
makePhases = ALL_MAKE_PHASES;
|
|
135
|
-
}
|
|
136
|
-
}),
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
return makePhases;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function requiredMakePhasesForArgs(steps: string[]): Set<PastoriaMakePhase> {
|
|
143
|
-
const validSteps = new Set(['schema', 'relay', 'router']);
|
|
144
|
-
const needs = new Set<PastoriaMakePhase>();
|
|
145
|
-
|
|
146
|
-
for (const step of steps) {
|
|
147
|
-
if (!validSteps.has(step)) {
|
|
148
|
-
throw new Error(
|
|
149
|
-
`Invalid build step: ${step}. Valid steps are: schema, relay, router`,
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
switch (step) {
|
|
154
|
-
case 'schema':
|
|
155
|
-
needs.add(PastoriaMakePhase.GRATS);
|
|
156
|
-
break;
|
|
157
|
-
case 'relay':
|
|
158
|
-
needs.add(PastoriaMakePhase.RELAY);
|
|
159
|
-
|
|
160
|
-
break;
|
|
161
|
-
case 'router':
|
|
162
|
-
needs.add(PastoriaMakePhase.PASTORIA_EXPORTS);
|
|
163
|
-
needs.add(PastoriaMakePhase.PASTORIA_ARTIFACTS);
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return needs;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
async function executeBuildSteps(
|
|
172
|
-
project: Project,
|
|
173
|
-
needs: Set<PastoriaMakePhase>,
|
|
174
|
-
): Promise<boolean> {
|
|
175
|
-
let rebuiltAnything = false;
|
|
176
|
-
let cachedMetadata: PastoriaMetadata | undefined = undefined;
|
|
177
|
-
|
|
178
|
-
if (needs.has(PastoriaMakePhase.PASTORIA_EXPORTS)) {
|
|
179
|
-
logInfo('Running Pastoria exports generation...');
|
|
180
|
-
cachedMetadata = await generatePastoriaExports(project);
|
|
181
|
-
rebuiltAnything = true;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (needs.has(PastoriaMakePhase.GRATS)) {
|
|
185
|
-
logInfo('Running Grats compiler...');
|
|
186
|
-
await runGratsCompiler();
|
|
187
|
-
rebuiltAnything = true;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (needs.has(PastoriaMakePhase.RELAY)) {
|
|
191
|
-
logInfo('Running Relay compiler...');
|
|
192
|
-
await runRelayCompiler();
|
|
193
|
-
rebuiltAnything = true;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (needs.has(PastoriaMakePhase.PASTORIA_ARTIFACTS)) {
|
|
197
|
-
logInfo('Running Pastoria artifacts generation...');
|
|
198
|
-
await generatePastoriaArtifacts(project, cachedMetadata);
|
|
199
|
-
rebuiltAnything = true;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return rebuiltAnything;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export async function createBuild(
|
|
206
|
-
steps: string[],
|
|
207
|
-
opts: {
|
|
208
|
-
alwaysMake: boolean;
|
|
209
|
-
release: boolean;
|
|
210
|
-
watch?: boolean;
|
|
211
|
-
},
|
|
212
|
-
) {
|
|
213
|
-
if (opts.watch && opts.release) {
|
|
214
|
-
throw new Error(
|
|
215
|
-
'Cannot use --watch and --release together. Watch mode is for development only.',
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
const project = new Project({
|
|
220
|
-
tsConfigFilePath: path.join(process.cwd(), 'tsconfig.json'),
|
|
221
|
-
manipulationSettings: {
|
|
222
|
-
indentationText: IndentationText.TwoSpaces,
|
|
223
|
-
},
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
const cwd = process.cwd();
|
|
227
|
-
let makePhases = new Set<PastoriaMakePhase>();
|
|
228
|
-
|
|
229
|
-
// If specific steps are provided, override automatic inference
|
|
230
|
-
if (steps.length > 0) {
|
|
231
|
-
makePhases = makePhases.union(requiredMakePhasesForArgs(steps));
|
|
232
|
-
} else if (opts.alwaysMake) {
|
|
233
|
-
makePhases = ALL_MAKE_PHASES;
|
|
234
|
-
}
|
|
235
|
-
// Use @parcel/watcher to get changes since last snapshot
|
|
236
|
-
else {
|
|
237
|
-
try {
|
|
238
|
-
// Check if snapshot exists - if not, do a full build
|
|
239
|
-
await access(SNAPSHOT_PATH);
|
|
240
|
-
|
|
241
|
-
// Get events since last snapshot
|
|
242
|
-
const events = await getEventsSince(cwd, SNAPSHOT_PATH);
|
|
243
|
-
|
|
244
|
-
if (events.length > 0) {
|
|
245
|
-
// Analyze which files changed and determine what needs to be rebuilt
|
|
246
|
-
makePhases = makePhases.union(
|
|
247
|
-
await requiredMakePhasesForChanges(events),
|
|
248
|
-
);
|
|
249
|
-
}
|
|
250
|
-
} catch (err) {
|
|
251
|
-
// No snapshot exists yet, or error reading it - do a full build
|
|
252
|
-
makePhases = ALL_MAKE_PHASES;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// Execute build pipeline conditionally
|
|
257
|
-
await executeBuildSteps(project, makePhases);
|
|
258
|
-
|
|
259
|
-
// Write snapshot for next incremental build
|
|
260
|
-
await writeSnapshot(cwd, SNAPSHOT_PATH);
|
|
261
|
-
|
|
262
|
-
if (opts.release) {
|
|
263
|
-
await build({
|
|
264
|
-
...createBuildConfig(CLIENT_BUILD),
|
|
265
|
-
configFile: false,
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
await build({
|
|
269
|
-
...createBuildConfig(SERVER_BUILD),
|
|
270
|
-
configFile: false,
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// Start watch mode if requested
|
|
275
|
-
if (opts.watch) {
|
|
276
|
-
logInfo('Watching for changes...');
|
|
277
|
-
|
|
278
|
-
const subscription = await ParcelWatcher.subscribe(
|
|
279
|
-
cwd,
|
|
280
|
-
async (err, events) => {
|
|
281
|
-
if (err) {
|
|
282
|
-
logger.error('Watch error!', {error: err});
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// Analyze which files changed and determine what needs to be rebuilt
|
|
287
|
-
const rebuiltAnything = await executeBuildSteps(
|
|
288
|
-
project,
|
|
289
|
-
await requiredMakePhasesForChanges(events),
|
|
290
|
-
);
|
|
291
|
-
|
|
292
|
-
if (rebuiltAnything) {
|
|
293
|
-
// Write snapshot after successful rebuild
|
|
294
|
-
await writeSnapshot(cwd, SNAPSHOT_PATH);
|
|
295
|
-
logInfo('Rebuild complete. Watching for changes...');
|
|
296
|
-
}
|
|
297
|
-
},
|
|
298
|
-
);
|
|
299
|
-
|
|
300
|
-
// Keep the process running
|
|
301
|
-
process.on('SIGINT', async () => {
|
|
302
|
-
await subscription.unsubscribe();
|
|
303
|
-
process.exit(0);
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
}
|