@synergenius/flow-weaver 0.17.7 → 0.17.8
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/api/parse.d.ts +5 -0
- package/dist/api/parse.js +4 -0
- package/dist/ast/types.d.ts +2 -0
- package/dist/cli/commands/compile.js +2 -1
- package/dist/cli/commands/init.js +15 -9
- package/dist/cli/commands/validate.js +1 -1
- package/dist/cli/exports.d.ts +17 -0
- package/dist/cli/exports.js +23 -0
- package/dist/cli/flow-weaver.mjs +59021 -62127
- package/dist/cli/templates/index.js +8 -1
- package/dist/extensions/index.d.ts +10 -6
- package/dist/extensions/index.js +11 -6
- package/dist/generated-version.d.ts +1 -1
- package/dist/generated-version.js +1 -1
- package/dist/generator/index.d.ts +11 -0
- package/dist/generator/index.js +11 -0
- package/dist/parser.d.ts +7 -0
- package/dist/parser.js +29 -0
- package/package.json +11 -7
- package/dist/extensions/cicd/base-target.d.ts +0 -110
- package/dist/extensions/cicd/base-target.js +0 -397
- package/dist/extensions/cicd/detection.d.ts +0 -33
- package/dist/extensions/cicd/detection.js +0 -88
- package/dist/extensions/cicd/docs/cicd.md +0 -395
- package/dist/extensions/cicd/index.d.ts +0 -15
- package/dist/extensions/cicd/index.js +0 -15
- package/dist/extensions/cicd/register.d.ts +0 -11
- package/dist/extensions/cicd/register.js +0 -62
- package/dist/extensions/cicd/rules.d.ts +0 -30
- package/dist/extensions/cicd/rules.js +0 -288
- package/dist/extensions/cicd/tag-handler.d.ts +0 -14
- package/dist/extensions/cicd/tag-handler.js +0 -504
- package/dist/extensions/cicd/templates/cicd-docker.d.ts +0 -9
- package/dist/extensions/cicd/templates/cicd-docker.js +0 -110
- package/dist/extensions/cicd/templates/cicd-matrix.d.ts +0 -9
- package/dist/extensions/cicd/templates/cicd-matrix.js +0 -112
- package/dist/extensions/cicd/templates/cicd-multi-env.d.ts +0 -9
- package/dist/extensions/cicd/templates/cicd-multi-env.js +0 -126
- package/dist/extensions/cicd/templates/cicd-test-deploy.d.ts +0 -11
- package/dist/extensions/cicd/templates/cicd-test-deploy.js +0 -156
- package/dist/extensions/inngest/dev-mode.d.ts +0 -9
- package/dist/extensions/inngest/dev-mode.js +0 -213
- package/dist/extensions/inngest/generator.d.ts +0 -53
- package/dist/extensions/inngest/generator.js +0 -1176
- package/dist/extensions/inngest/index.d.ts +0 -2
- package/dist/extensions/inngest/index.js +0 -2
- package/dist/extensions/inngest/register.d.ts +0 -6
- package/dist/extensions/inngest/register.js +0 -23
- package/dist/extensions/inngest/templates/ai-agent-durable.d.ts +0 -8
- package/dist/extensions/inngest/templates/ai-agent-durable.js +0 -334
- package/dist/extensions/inngest/templates/ai-pipeline-durable.d.ts +0 -8
- package/dist/extensions/inngest/templates/ai-pipeline-durable.js +0 -326
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CI/CD: Matrix Testing template
|
|
3
|
-
*
|
|
4
|
-
* Generates a pipeline with matrix strategy for testing across
|
|
5
|
-
* multiple Node.js versions and/or operating systems.
|
|
6
|
-
*/
|
|
7
|
-
const configSchema = {
|
|
8
|
-
platform: {
|
|
9
|
-
type: 'select',
|
|
10
|
-
label: 'CI/CD Platform',
|
|
11
|
-
default: 'github-actions',
|
|
12
|
-
options: [
|
|
13
|
-
{ value: 'github-actions', label: 'GitHub Actions' },
|
|
14
|
-
{ value: 'gitlab-ci', label: 'GitLab CI' },
|
|
15
|
-
],
|
|
16
|
-
},
|
|
17
|
-
versions: {
|
|
18
|
-
type: 'string',
|
|
19
|
-
label: 'Node.js Versions',
|
|
20
|
-
description: 'Comma-separated versions to test',
|
|
21
|
-
default: '18,20,22',
|
|
22
|
-
},
|
|
23
|
-
operatingSystems: {
|
|
24
|
-
type: 'string',
|
|
25
|
-
label: 'Operating Systems',
|
|
26
|
-
description: 'Comma-separated OS labels',
|
|
27
|
-
default: 'ubuntu-latest',
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
export const cicdMatrixTemplate = {
|
|
31
|
-
id: 'cicd-matrix',
|
|
32
|
-
name: 'CI/CD: Matrix Testing',
|
|
33
|
-
description: 'Test across multiple Node.js versions and operating systems',
|
|
34
|
-
category: 'automation',
|
|
35
|
-
configSchema,
|
|
36
|
-
generate: (opts) => {
|
|
37
|
-
const name = opts.workflowName || 'matrixTest';
|
|
38
|
-
const versions = (opts.config?.versions || '18,20,22')
|
|
39
|
-
.split(',')
|
|
40
|
-
.map((v) => v.trim());
|
|
41
|
-
const oses = (opts.config?.operatingSystems || 'ubuntu-latest')
|
|
42
|
-
.split(',')
|
|
43
|
-
.map((o) => o.trim());
|
|
44
|
-
const matrixNode = ` * @matrix node="${versions.join(',')}" os="${oses.join(',')}"`;
|
|
45
|
-
return `/** @flowWeaver nodeType
|
|
46
|
-
* @expression
|
|
47
|
-
* @label Checkout code
|
|
48
|
-
*/
|
|
49
|
-
function checkout(): { repo: string } { return { repo: '.' }; }
|
|
50
|
-
|
|
51
|
-
/** @flowWeaver nodeType
|
|
52
|
-
* @expression
|
|
53
|
-
* @label Setup Node.js
|
|
54
|
-
*/
|
|
55
|
-
function setupNode(): { nodeVersion: string } { return { nodeVersion: '20' }; }
|
|
56
|
-
|
|
57
|
-
/** @flowWeaver nodeType
|
|
58
|
-
* @expression
|
|
59
|
-
* @label Install dependencies
|
|
60
|
-
*/
|
|
61
|
-
function npmInstall(): { installed: boolean } { return { installed: true }; }
|
|
62
|
-
|
|
63
|
-
/** @flowWeaver nodeType
|
|
64
|
-
* @expression
|
|
65
|
-
* @label Run shell command
|
|
66
|
-
*/
|
|
67
|
-
function shellCommand(): { exitCode: number } { return { exitCode: 0 }; }
|
|
68
|
-
|
|
69
|
-
/** @flowWeaver nodeType
|
|
70
|
-
* @expression
|
|
71
|
-
* @label Run tests
|
|
72
|
-
*/
|
|
73
|
-
function npmTest(): { exitCode: number } { return { exitCode: 0 }; }
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* @flowWeaver workflow
|
|
77
|
-
* @trigger push branches="main"
|
|
78
|
-
* @trigger pull_request branches="main"
|
|
79
|
-
* @runner ubuntu-latest
|
|
80
|
-
${matrixNode}
|
|
81
|
-
* @cache npm key="package-lock.json"
|
|
82
|
-
*
|
|
83
|
-
* @node co checkout [job: "test"] [position: 270 0]
|
|
84
|
-
* @node setup setupNode [job: "test"] [position: 540 0]
|
|
85
|
-
* @node install npmInstall [job: "test"] [position: 810 0]
|
|
86
|
-
* @node lint shellCommand [job: "test"] [position: 1080 0]
|
|
87
|
-
* @node test npmTest [job: "test"] [position: 1350 0]
|
|
88
|
-
*
|
|
89
|
-
* @path Start -> co -> setup -> install -> lint -> test -> Exit
|
|
90
|
-
* @position Start 0 0
|
|
91
|
-
* @position Exit 1620 0
|
|
92
|
-
* @connect test.exitCode -> Exit.testResult
|
|
93
|
-
*
|
|
94
|
-
* @param execute [order:-1] - Execute
|
|
95
|
-
* @param params [order:0] - Params
|
|
96
|
-
* @returns onSuccess [order:-2] - On Success
|
|
97
|
-
* @returns onFailure [order:-1] - On Failure
|
|
98
|
-
* @returns testResult [order:0] - Test result
|
|
99
|
-
*/
|
|
100
|
-
export async function ${name}(
|
|
101
|
-
execute: boolean,
|
|
102
|
-
params: Record<string, never> = {},
|
|
103
|
-
): Promise<{ onSuccess: boolean; onFailure: boolean; testResult: string | null }> {
|
|
104
|
-
// @flow-weaver-body-start
|
|
105
|
-
throw new Error('Compile with: npx flow-weaver compile <this-file>');
|
|
106
|
-
// @flow-weaver-body-end
|
|
107
|
-
return { onSuccess: false, onFailure: true, testResult: null };
|
|
108
|
-
}
|
|
109
|
-
`;
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
//# sourceMappingURL=cicd-matrix.js.map
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CI/CD: Multi-Environment Deploy template
|
|
3
|
-
*
|
|
4
|
-
* Generates a pipeline with staging → production promotion:
|
|
5
|
-
* test → deploy-staging → deploy-production (with environment protection)
|
|
6
|
-
*/
|
|
7
|
-
import type { WorkflowTemplate } from '../../../cli/templates/index.js';
|
|
8
|
-
export declare const cicdMultiEnvTemplate: WorkflowTemplate;
|
|
9
|
-
//# sourceMappingURL=cicd-multi-env.d.ts.map
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CI/CD: Multi-Environment Deploy template
|
|
3
|
-
*
|
|
4
|
-
* Generates a pipeline with staging → production promotion:
|
|
5
|
-
* test → deploy-staging → deploy-production (with environment protection)
|
|
6
|
-
*/
|
|
7
|
-
const configSchema = {
|
|
8
|
-
platform: {
|
|
9
|
-
type: 'select',
|
|
10
|
-
label: 'CI/CD Platform',
|
|
11
|
-
default: 'github-actions',
|
|
12
|
-
options: [
|
|
13
|
-
{ value: 'github-actions', label: 'GitHub Actions' },
|
|
14
|
-
{ value: 'gitlab-ci', label: 'GitLab CI' },
|
|
15
|
-
],
|
|
16
|
-
},
|
|
17
|
-
environments: {
|
|
18
|
-
type: 'string',
|
|
19
|
-
label: 'Environments',
|
|
20
|
-
description: 'Comma-separated environment names',
|
|
21
|
-
default: 'staging,production',
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
export const cicdMultiEnvTemplate = {
|
|
25
|
-
id: 'cicd-multi-env',
|
|
26
|
-
name: 'CI/CD: Multi-Environment',
|
|
27
|
-
description: 'Multi-environment deployment pipeline with staging and production stages',
|
|
28
|
-
category: 'automation',
|
|
29
|
-
configSchema,
|
|
30
|
-
generate: (opts) => {
|
|
31
|
-
const name = opts.workflowName || 'multiEnvPipeline';
|
|
32
|
-
const envs = (opts.config?.environments || 'staging,production')
|
|
33
|
-
.split(',')
|
|
34
|
-
.map((e) => e.trim());
|
|
35
|
-
const envAnnotations = envs
|
|
36
|
-
.map((env) => ` * @environment ${env} url="https://${env}.example.com"`)
|
|
37
|
-
.join('\n');
|
|
38
|
-
const stageAnnotations = ` * @stage test\n * @stage build\n * @stage deploy\n`;
|
|
39
|
-
const jobAnnotations = [
|
|
40
|
-
` * @job test retry=1`,
|
|
41
|
-
` * @job build timeout="10m"`,
|
|
42
|
-
...envs.map((env) => ` * @job deploy-${env} allow_failure=${env === 'staging' ? 'true' : 'false'}`),
|
|
43
|
-
].join('\n');
|
|
44
|
-
let x = 270;
|
|
45
|
-
const nodeAnnotations = [];
|
|
46
|
-
const pathParts = ['Start'];
|
|
47
|
-
// Test job
|
|
48
|
-
nodeAnnotations.push(` * @node co checkout [job: "test"] [position: ${x} 0]`);
|
|
49
|
-
pathParts.push('co');
|
|
50
|
-
x += 270;
|
|
51
|
-
nodeAnnotations.push(` * @node test npmTest [job: "test"] [position: ${x} 0]`);
|
|
52
|
-
pathParts.push('test');
|
|
53
|
-
x += 270;
|
|
54
|
-
nodeAnnotations.push(` * @node build npmBuild [job: "build"] [position: ${x} 0]`);
|
|
55
|
-
pathParts.push('build');
|
|
56
|
-
x += 270;
|
|
57
|
-
// Deploy jobs for each environment
|
|
58
|
-
for (const env of envs) {
|
|
59
|
-
const id = `deploy_${env.replace(/[^a-zA-Z0-9]/g, '_')}`;
|
|
60
|
-
nodeAnnotations.push(` * @node ${id} deploySsh [job: "deploy-${env}"] [environment: "${env}"] [position: ${x} 0]`);
|
|
61
|
-
pathParts.push(id);
|
|
62
|
-
x += 270;
|
|
63
|
-
}
|
|
64
|
-
pathParts.push('Exit');
|
|
65
|
-
return `/** @flowWeaver nodeType
|
|
66
|
-
* @expression
|
|
67
|
-
* @label Checkout code
|
|
68
|
-
*/
|
|
69
|
-
function checkout(): { repo: string } { return { repo: '.' }; }
|
|
70
|
-
|
|
71
|
-
/** @flowWeaver nodeType
|
|
72
|
-
* @expression
|
|
73
|
-
* @label Run tests
|
|
74
|
-
*/
|
|
75
|
-
function npmTest(): { exitCode: number } { return { exitCode: 0 }; }
|
|
76
|
-
|
|
77
|
-
/** @flowWeaver nodeType
|
|
78
|
-
* @expression
|
|
79
|
-
* @label Build project
|
|
80
|
-
*/
|
|
81
|
-
function npmBuild(): { output: string } { return { output: 'dist/' }; }
|
|
82
|
-
|
|
83
|
-
/** @flowWeaver nodeType
|
|
84
|
-
* @expression
|
|
85
|
-
* @label Deploy via SSH
|
|
86
|
-
*/
|
|
87
|
-
function deploySsh(sshKey: string = ''): { result: string } { return { result: 'deployed' }; }
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* @flowWeaver workflow
|
|
91
|
-
* @trigger push branches="main"
|
|
92
|
-
* @runner ubuntu-latest
|
|
93
|
-
* @secret DEPLOY_KEY - SSH deployment key
|
|
94
|
-
${envAnnotations}
|
|
95
|
-
* @cache npm key="package-lock.json"
|
|
96
|
-
* @artifact dist path="dist/" retention=3
|
|
97
|
-
*
|
|
98
|
-
${stageAnnotations}${jobAnnotations}
|
|
99
|
-
*
|
|
100
|
-
${nodeAnnotations.join('\n')}
|
|
101
|
-
*
|
|
102
|
-
* @path ${pathParts.join(' -> ')}
|
|
103
|
-
* @position Start 0 0
|
|
104
|
-
* @position Exit ${x} 0
|
|
105
|
-
* @connect secret:DEPLOY_KEY -> ${`deploy_${envs[0].replace(/[^a-zA-Z0-9]/g, '_')}`}.sshKey
|
|
106
|
-
${envs.slice(1).map((env) => ` * @connect secret:DEPLOY_KEY -> deploy_${env.replace(/[^a-zA-Z0-9]/g, '_')}.sshKey`).join('\n')}
|
|
107
|
-
*
|
|
108
|
-
* @param execute [order:-1] - Execute
|
|
109
|
-
* @param params [order:0] - Params
|
|
110
|
-
* @returns onSuccess [order:-2] - On Success
|
|
111
|
-
* @returns onFailure [order:-1] - On Failure
|
|
112
|
-
* @returns summary [order:0] - Deployment summary
|
|
113
|
-
*/
|
|
114
|
-
export async function ${name}(
|
|
115
|
-
execute: boolean,
|
|
116
|
-
params: Record<string, never> = {},
|
|
117
|
-
): Promise<{ onSuccess: boolean; onFailure: boolean; summary: string | null }> {
|
|
118
|
-
// @flow-weaver-body-start
|
|
119
|
-
throw new Error('Compile with: npx flow-weaver compile <this-file>');
|
|
120
|
-
// @flow-weaver-body-end
|
|
121
|
-
return { onSuccess: false, onFailure: true, summary: null };
|
|
122
|
-
}
|
|
123
|
-
`;
|
|
124
|
-
},
|
|
125
|
-
};
|
|
126
|
-
//# sourceMappingURL=cicd-multi-env.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CI/CD: Test and Deploy template
|
|
3
|
-
*
|
|
4
|
-
* Generates a Flow Weaver workflow for a standard CI/CD pipeline:
|
|
5
|
-
* checkout → setup → install → test → build → deploy
|
|
6
|
-
*
|
|
7
|
-
* Exports to GitHub Actions or GitLab CI via `fw_export`.
|
|
8
|
-
*/
|
|
9
|
-
import type { WorkflowTemplate } from '../../../cli/templates/index.js';
|
|
10
|
-
export declare const cicdTestDeployTemplate: WorkflowTemplate;
|
|
11
|
-
//# sourceMappingURL=cicd-test-deploy.d.ts.map
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CI/CD: Test and Deploy template
|
|
3
|
-
*
|
|
4
|
-
* Generates a Flow Weaver workflow for a standard CI/CD pipeline:
|
|
5
|
-
* checkout → setup → install → test → build → deploy
|
|
6
|
-
*
|
|
7
|
-
* Exports to GitHub Actions or GitLab CI via `fw_export`.
|
|
8
|
-
*/
|
|
9
|
-
const configSchema = {
|
|
10
|
-
platform: {
|
|
11
|
-
type: 'select',
|
|
12
|
-
label: 'CI/CD Platform',
|
|
13
|
-
description: 'Target CI/CD platform for export',
|
|
14
|
-
default: 'github-actions',
|
|
15
|
-
options: [
|
|
16
|
-
{ value: 'github-actions', label: 'GitHub Actions' },
|
|
17
|
-
{ value: 'gitlab-ci', label: 'GitLab CI' },
|
|
18
|
-
],
|
|
19
|
-
},
|
|
20
|
-
nodeVersion: {
|
|
21
|
-
type: 'string',
|
|
22
|
-
label: 'Node.js Version',
|
|
23
|
-
default: '20',
|
|
24
|
-
description: 'Node.js version for setup-node step',
|
|
25
|
-
},
|
|
26
|
-
deployTarget: {
|
|
27
|
-
type: 'select',
|
|
28
|
-
label: 'Deploy Method',
|
|
29
|
-
default: 'ssh',
|
|
30
|
-
options: [
|
|
31
|
-
{ value: 'ssh', label: 'SSH Deploy' },
|
|
32
|
-
{ value: 's3', label: 'AWS S3' },
|
|
33
|
-
{ value: 'none', label: 'No deploy (test only)' },
|
|
34
|
-
],
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
export const cicdTestDeployTemplate = {
|
|
38
|
-
id: 'cicd-test-deploy',
|
|
39
|
-
name: 'CI/CD: Test and Deploy',
|
|
40
|
-
description: 'Standard test-and-deploy pipeline with checkout, setup, test, build, and deploy stages',
|
|
41
|
-
category: 'automation',
|
|
42
|
-
configSchema,
|
|
43
|
-
generate: (opts) => {
|
|
44
|
-
const name = opts.workflowName || 'ciPipeline';
|
|
45
|
-
const deployTarget = opts.config?.deployTarget || 'ssh';
|
|
46
|
-
const hasDeploy = deployTarget !== 'none';
|
|
47
|
-
const deployNodeType = deployTarget === 'ssh' ? 'deploySsh' : 'deployS3';
|
|
48
|
-
const deployNode = hasDeploy
|
|
49
|
-
? `\n * @node deploy ${deployNodeType} [job: "deploy"] [environment: "production"] [position: 1620 0]`
|
|
50
|
-
: '';
|
|
51
|
-
const deployPath = hasDeploy ? ' -> deploy' : '';
|
|
52
|
-
const deploySecret = deployTarget === 'ssh'
|
|
53
|
-
? '\n * @secret DEPLOY_KEY - SSH key for deployment'
|
|
54
|
-
: deployTarget === 's3'
|
|
55
|
-
? '\n * @secret AWS_ACCESS_KEY_ID - AWS access key\n * @secret AWS_SECRET_ACCESS_KEY - AWS secret key'
|
|
56
|
-
: '';
|
|
57
|
-
const deployConnect = deployTarget === 'ssh'
|
|
58
|
-
? '\n * @connect secret:DEPLOY_KEY -> deploy.sshKey'
|
|
59
|
-
: deployTarget === 's3'
|
|
60
|
-
? '\n * @connect secret:AWS_ACCESS_KEY_ID -> deploy.accessKey\n * @connect secret:AWS_SECRET_ACCESS_KEY -> deploy.secretKey'
|
|
61
|
-
: '';
|
|
62
|
-
const deployReturns = hasDeploy ? '\n * @returns deployResult [order:3] - Deploy result' : '';
|
|
63
|
-
const deployConnect2 = hasDeploy ? '\n * @connect deploy.result -> Exit.deployResult' : '';
|
|
64
|
-
const deployStub = hasDeploy
|
|
65
|
-
? deployTarget === 'ssh'
|
|
66
|
-
? `
|
|
67
|
-
/** @flowWeaver nodeType
|
|
68
|
-
* @expression
|
|
69
|
-
* @label Deploy via SSH
|
|
70
|
-
*/
|
|
71
|
-
function deploySsh(sshKey: string = ''): { result: string } { return { result: 'deployed' }; }
|
|
72
|
-
`
|
|
73
|
-
: `
|
|
74
|
-
/** @flowWeaver nodeType
|
|
75
|
-
* @expression
|
|
76
|
-
* @label Deploy to S3
|
|
77
|
-
*/
|
|
78
|
-
function deployS3(accessKey: string = '', secretKey: string = ''): { result: string } { return { result: 'deployed' }; }
|
|
79
|
-
`
|
|
80
|
-
: '';
|
|
81
|
-
const stageAnnotations = hasDeploy
|
|
82
|
-
? ` * @stage test\n * @stage build\n * @stage deploy\n`
|
|
83
|
-
: ` * @stage test\n * @stage build\n`;
|
|
84
|
-
const jobAnnotations = hasDeploy
|
|
85
|
-
? ` * @job test retry=1\n * @job build timeout="10m"\n * @job deploy allow_failure=false\n`
|
|
86
|
-
: ` * @job test retry=1\n * @job build timeout="10m"\n`;
|
|
87
|
-
return `/** @flowWeaver nodeType
|
|
88
|
-
* @expression
|
|
89
|
-
* @label Checkout code
|
|
90
|
-
*/
|
|
91
|
-
function checkout(): { repo: string } { return { repo: '.' }; }
|
|
92
|
-
|
|
93
|
-
/** @flowWeaver nodeType
|
|
94
|
-
* @expression
|
|
95
|
-
* @label Setup Node.js
|
|
96
|
-
*/
|
|
97
|
-
function setupNode(): { nodeVersion: string } { return { nodeVersion: '20' }; }
|
|
98
|
-
|
|
99
|
-
/** @flowWeaver nodeType
|
|
100
|
-
* @expression
|
|
101
|
-
* @label Install dependencies
|
|
102
|
-
*/
|
|
103
|
-
function npmInstall(npmToken: string = ''): { installed: boolean } { return { installed: true }; }
|
|
104
|
-
|
|
105
|
-
/** @flowWeaver nodeType
|
|
106
|
-
* @expression
|
|
107
|
-
* @label Run tests
|
|
108
|
-
*/
|
|
109
|
-
function npmTest(): { exitCode: number } { return { exitCode: 0 }; }
|
|
110
|
-
|
|
111
|
-
/** @flowWeaver nodeType
|
|
112
|
-
* @expression
|
|
113
|
-
* @label Build project
|
|
114
|
-
*/
|
|
115
|
-
function npmBuild(): { output: string } { return { output: 'dist/' }; }
|
|
116
|
-
${deployStub}
|
|
117
|
-
/**
|
|
118
|
-
* @flowWeaver workflow
|
|
119
|
-
* @trigger push branches="main"
|
|
120
|
-
* @trigger pull_request branches="main"
|
|
121
|
-
* @runner ubuntu-latest
|
|
122
|
-
* @secret NPM_TOKEN - npm auth token${deploySecret}
|
|
123
|
-
* @cache npm key="package-lock.json"
|
|
124
|
-
*
|
|
125
|
-
${stageAnnotations}${jobAnnotations} *
|
|
126
|
-
* @node co checkout [job: "test"] [position: 270 0]
|
|
127
|
-
* @node setup setupNode [job: "test"] [position: 540 0]
|
|
128
|
-
* @node install npmInstall [job: "test"] [position: 810 0]
|
|
129
|
-
* @node test npmTest [job: "test"] [position: 1080 0]
|
|
130
|
-
* @node build npmBuild [job: "build"] [position: 1350 0]${deployNode}
|
|
131
|
-
*
|
|
132
|
-
* @path Start -> co -> setup -> install -> test -> build${deployPath} -> Exit
|
|
133
|
-
* @position Start 0 0
|
|
134
|
-
* @position Exit ${hasDeploy ? '1890' : '1620'} 0
|
|
135
|
-
* @connect secret:NPM_TOKEN -> install.npmToken${deployConnect}
|
|
136
|
-
* @connect build.output -> Exit.buildOutput${deployConnect2}
|
|
137
|
-
*
|
|
138
|
-
* @param execute [order:-1] - Execute
|
|
139
|
-
* @param params [order:0] - Params
|
|
140
|
-
* @returns onSuccess [order:-2] - On Success
|
|
141
|
-
* @returns onFailure [order:-1] - On Failure
|
|
142
|
-
* @returns buildOutput [order:0] - Build output path${deployReturns}
|
|
143
|
-
*/
|
|
144
|
-
export async function ${name}(
|
|
145
|
-
execute: boolean,
|
|
146
|
-
params: Record<string, never> = {},
|
|
147
|
-
): Promise<{ onSuccess: boolean; onFailure: boolean; buildOutput: string | null${hasDeploy ? '; deployResult: string | null' : ''} }> {
|
|
148
|
-
// @flow-weaver-body-start
|
|
149
|
-
throw new Error('Compile with: npx flow-weaver compile <this-file>');
|
|
150
|
-
// @flow-weaver-body-end
|
|
151
|
-
return { onSuccess: false, onFailure: true, buildOutput: null${hasDeploy ? ', deployResult: null' : ''} };
|
|
152
|
-
}
|
|
153
|
-
`;
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
//# sourceMappingURL=cicd-test-deploy.js.map
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Inngest dev mode provider.
|
|
3
|
-
*
|
|
4
|
-
* Compiles a workflow to an Inngest function, generates a local dev server
|
|
5
|
-
* entry (express or hono), and watches for file changes.
|
|
6
|
-
*/
|
|
7
|
-
import type { DevModeOptions } from '../../generator/dev-mode-registry.js';
|
|
8
|
-
export declare function runInngestDevMode(filePath: string, options: DevModeOptions): Promise<void>;
|
|
9
|
-
//# sourceMappingURL=dev-mode.d.ts.map
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Inngest dev mode provider.
|
|
3
|
-
*
|
|
4
|
-
* Compiles a workflow to an Inngest function, generates a local dev server
|
|
5
|
-
* entry (express or hono), and watches for file changes.
|
|
6
|
-
*/
|
|
7
|
-
import * as path from 'path';
|
|
8
|
-
import * as fs from 'fs';
|
|
9
|
-
import * as os from 'os';
|
|
10
|
-
import { glob } from 'glob';
|
|
11
|
-
import { spawn } from 'child_process';
|
|
12
|
-
import { compileCustomTarget } from '../../cli/commands/compile.js';
|
|
13
|
-
import { logger } from '../../cli/utils/logger.js';
|
|
14
|
-
import { getErrorMessage } from '../../utils/error-utils.js';
|
|
15
|
-
function timestamp() {
|
|
16
|
-
const now = new Date();
|
|
17
|
-
const h = String(now.getHours()).padStart(2, '0');
|
|
18
|
-
const m = String(now.getMinutes()).padStart(2, '0');
|
|
19
|
-
const s = String(now.getSeconds()).padStart(2, '0');
|
|
20
|
-
return `${h}:${m}:${s}`;
|
|
21
|
-
}
|
|
22
|
-
function cycleSeparator(file) {
|
|
23
|
-
const ts = timestamp();
|
|
24
|
-
const pad = '─'.repeat(40);
|
|
25
|
-
logger.log(`\n ${logger.dim(`─── ${ts} ${pad}`)}`);
|
|
26
|
-
if (file) {
|
|
27
|
-
logger.log(` ${logger.dim('File changed:')} ${path.basename(file)}`);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function checkDependency(pkg, cwd) {
|
|
31
|
-
try {
|
|
32
|
-
require.resolve(pkg, { paths: [cwd] });
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
function generateDevServerEntry(inngestOutputPath, framework, port) {
|
|
40
|
-
const relImport = `./${path.basename(inngestOutputPath).replace(/\.ts$/, '.js')}`;
|
|
41
|
-
if (framework === 'express') {
|
|
42
|
-
return `import express from 'express';
|
|
43
|
-
import { handler } from '${relImport}';
|
|
44
|
-
|
|
45
|
-
const app = express();
|
|
46
|
-
app.use(express.json());
|
|
47
|
-
app.use('/api/inngest', handler);
|
|
48
|
-
app.listen(${port}, () => {
|
|
49
|
-
console.log('Inngest dev server running on http://localhost:${port}');
|
|
50
|
-
console.log('Inngest endpoint: http://localhost:${port}/api/inngest');
|
|
51
|
-
console.log('');
|
|
52
|
-
console.log('Connect Inngest Dev Server:');
|
|
53
|
-
console.log(' npx inngest-cli@latest dev -u http://localhost:${port}/api/inngest');
|
|
54
|
-
});
|
|
55
|
-
`;
|
|
56
|
-
}
|
|
57
|
-
if (framework === 'hono') {
|
|
58
|
-
return `import { Hono } from 'hono';
|
|
59
|
-
import { serve } from '@hono/node-server';
|
|
60
|
-
import { handler } from '${relImport}';
|
|
61
|
-
|
|
62
|
-
const app = new Hono();
|
|
63
|
-
app.route('/api/inngest', handler);
|
|
64
|
-
|
|
65
|
-
serve({ fetch: app.fetch, port: ${port} }, () => {
|
|
66
|
-
console.log('Inngest dev server running on http://localhost:${port}');
|
|
67
|
-
console.log('Inngest endpoint: http://localhost:${port}/api/inngest');
|
|
68
|
-
console.log('');
|
|
69
|
-
console.log('Connect Inngest Dev Server:');
|
|
70
|
-
console.log(' npx inngest-cli@latest dev -u http://localhost:${port}/api/inngest');
|
|
71
|
-
});
|
|
72
|
-
`;
|
|
73
|
-
}
|
|
74
|
-
// Default: express
|
|
75
|
-
return generateDevServerEntry(inngestOutputPath, 'express', port);
|
|
76
|
-
}
|
|
77
|
-
export async function runInngestDevMode(filePath, options) {
|
|
78
|
-
const framework = options.framework ?? 'express';
|
|
79
|
-
const port = options.port ?? 3000;
|
|
80
|
-
const cwd = path.dirname(filePath);
|
|
81
|
-
// Check dependencies
|
|
82
|
-
const missingDeps = [];
|
|
83
|
-
if (!checkDependency('inngest', cwd))
|
|
84
|
-
missingDeps.push('inngest');
|
|
85
|
-
if (framework === 'express' && !checkDependency('express', cwd))
|
|
86
|
-
missingDeps.push('express');
|
|
87
|
-
if (framework === 'hono') {
|
|
88
|
-
if (!checkDependency('hono', cwd))
|
|
89
|
-
missingDeps.push('hono');
|
|
90
|
-
if (!checkDependency('@hono/node-server', cwd))
|
|
91
|
-
missingDeps.push('@hono/node-server');
|
|
92
|
-
}
|
|
93
|
-
if (missingDeps.length > 0) {
|
|
94
|
-
throw new Error(`Missing dependencies: ${missingDeps.join(', ')}. Install them with: npm install ${missingDeps.join(' ')}`);
|
|
95
|
-
}
|
|
96
|
-
// Set up temp directory for generated files
|
|
97
|
-
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'fw-inngest-dev-'));
|
|
98
|
-
const inngestOutputPath = path.join(tmpDir, path.basename(filePath).replace(/\.ts$/, '.inngest.ts'));
|
|
99
|
-
let serverProcess = null;
|
|
100
|
-
const compileInngest = async () => {
|
|
101
|
-
try {
|
|
102
|
-
await compileCustomTarget('inngest', filePath, {
|
|
103
|
-
production: false,
|
|
104
|
-
workflowName: options.workflow,
|
|
105
|
-
serve: true,
|
|
106
|
-
framework: framework,
|
|
107
|
-
typedEvents: true,
|
|
108
|
-
});
|
|
109
|
-
// compileCustomTarget writes to filePath.replace(.ts, .inngest.ts)
|
|
110
|
-
// Copy it to our temp dir, then remove the source-adjacent file
|
|
111
|
-
const sourceOutput = filePath.replace(/\.ts$/, '.inngest.ts');
|
|
112
|
-
if (fs.existsSync(sourceOutput)) {
|
|
113
|
-
fs.copyFileSync(sourceOutput, inngestOutputPath);
|
|
114
|
-
try {
|
|
115
|
-
fs.unlinkSync(sourceOutput);
|
|
116
|
-
}
|
|
117
|
-
catch { /* ignore */ }
|
|
118
|
-
}
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
logger.error(`Compilation failed: ${getErrorMessage(error)}`);
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
const startServer = () => {
|
|
127
|
-
const entryPath = path.join(tmpDir, 'dev-server.ts');
|
|
128
|
-
const entryCode = generateDevServerEntry(inngestOutputPath, framework, port);
|
|
129
|
-
fs.writeFileSync(entryPath, entryCode, 'utf8');
|
|
130
|
-
serverProcess = spawn('npx', ['tsx', entryPath], {
|
|
131
|
-
cwd: path.dirname(filePath),
|
|
132
|
-
stdio: 'inherit',
|
|
133
|
-
shell: true,
|
|
134
|
-
});
|
|
135
|
-
serverProcess.on('error', (err) => {
|
|
136
|
-
logger.error(`Server process error: ${err.message}`);
|
|
137
|
-
});
|
|
138
|
-
serverProcess.on('exit', (code) => {
|
|
139
|
-
if (code !== null && code !== 0) {
|
|
140
|
-
logger.error(`Server exited with code ${code}`);
|
|
141
|
-
}
|
|
142
|
-
serverProcess = null;
|
|
143
|
-
});
|
|
144
|
-
};
|
|
145
|
-
const stopServer = () => {
|
|
146
|
-
if (serverProcess && !serverProcess.killed) {
|
|
147
|
-
serverProcess.kill();
|
|
148
|
-
serverProcess = null;
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
const restartServer = async () => {
|
|
152
|
-
stopServer();
|
|
153
|
-
const ok = await compileInngest();
|
|
154
|
-
if (ok) {
|
|
155
|
-
startServer();
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
// Header
|
|
159
|
-
logger.section('Inngest Dev Mode');
|
|
160
|
-
logger.info(`File: ${path.basename(filePath)}`);
|
|
161
|
-
logger.info(`Framework: ${framework}`);
|
|
162
|
-
logger.info(`Port: ${port}`);
|
|
163
|
-
logger.newline();
|
|
164
|
-
// Initial compile + start
|
|
165
|
-
const ok = await compileInngest();
|
|
166
|
-
if (!ok) {
|
|
167
|
-
if (options.once)
|
|
168
|
-
return;
|
|
169
|
-
logger.info('Fix the errors above, then save the file to retry.');
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
if (options.once)
|
|
173
|
-
return;
|
|
174
|
-
startServer();
|
|
175
|
-
}
|
|
176
|
-
// Watch for changes
|
|
177
|
-
logger.newline();
|
|
178
|
-
logger.success('Watching for file changes... (Ctrl+C to stop)');
|
|
179
|
-
const files = await glob(path.resolve(filePath), { absolute: true });
|
|
180
|
-
const chokidar = await import('chokidar');
|
|
181
|
-
const watcher = chokidar.watch(files, {
|
|
182
|
-
persistent: true,
|
|
183
|
-
ignoreInitial: true,
|
|
184
|
-
});
|
|
185
|
-
watcher.on('change', async (file) => {
|
|
186
|
-
cycleSeparator(file);
|
|
187
|
-
logger.info('Recompiling and restarting server...');
|
|
188
|
-
await restartServer();
|
|
189
|
-
});
|
|
190
|
-
// Cleanup
|
|
191
|
-
const sourceOutput = filePath.replace(/\.ts$/, '.inngest.ts');
|
|
192
|
-
const cleanup = () => {
|
|
193
|
-
logger.newline();
|
|
194
|
-
logger.info('Stopping dev mode...');
|
|
195
|
-
stopServer();
|
|
196
|
-
watcher.close();
|
|
197
|
-
try {
|
|
198
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
199
|
-
}
|
|
200
|
-
catch { /* ignore */ }
|
|
201
|
-
try {
|
|
202
|
-
fs.unlinkSync(sourceOutput);
|
|
203
|
-
}
|
|
204
|
-
catch { /* ignore */ }
|
|
205
|
-
process.exit(0);
|
|
206
|
-
};
|
|
207
|
-
process.on('SIGINT', cleanup);
|
|
208
|
-
if (process.platform !== 'win32')
|
|
209
|
-
process.on('SIGTERM', cleanup);
|
|
210
|
-
// Keep process alive
|
|
211
|
-
await new Promise(() => { });
|
|
212
|
-
}
|
|
213
|
-
//# sourceMappingURL=dev-mode.js.map
|