@fnet/cli 0.100.2 → 0.101.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/fnet/index.B5vpZn1Z.js +53 -0
- package/dist/fnet/index.B6WHm9H0.js +106 -0
- package/dist/fnet/index.B90Vm9uq.js +114 -0
- package/dist/fnet/index.BMsD46br.js +60 -0
- package/dist/fnet/index.BUhoGq-h.js +70 -0
- package/dist/fnet/index.BjzEMdm1.js +52 -0
- package/dist/fnet/index.C9zKEF61.js +106 -0
- package/dist/fnet/index.CQNYMi1Z.js +51 -0
- package/dist/fnet/index.CX8eMqfH.js +191 -0
- package/dist/fnet/index.Ce8sTnt_.js +52 -0
- package/dist/fnet/index.D2kFuxXo.js +52 -0
- package/dist/fnet/index.D61MduW1.js +106 -0
- package/dist/fnet/index.Dd0lngp8.js +41 -0
- package/dist/fnet/index.DqwVukIB.js +52 -0
- package/dist/fnet/index.MWHLt6g3.js +52 -0
- package/dist/fnet/index.f798DPwo.js +93 -0
- package/dist/fnet/index.j5JP-zGw.js +52 -0
- package/dist/fnet/index.js +4562 -0
- package/dist/fnode/index.B5vpZn1Z.js +53 -0
- package/dist/fnode/index.B6WHm9H0.js +106 -0
- package/dist/fnode/index.BMsD46br.js +60 -0
- package/dist/fnode/index.BNSTS5o6.js +109 -0
- package/dist/fnode/index.BUhoGq-h.js +70 -0
- package/dist/fnode/index.BjzEMdm1.js +52 -0
- package/dist/fnode/index.C9zKEF61.js +106 -0
- package/dist/fnode/index.CQNYMi1Z.js +51 -0
- package/dist/fnode/index.CX8eMqfH.js +191 -0
- package/dist/fnode/index.Ce8sTnt_.js +52 -0
- package/dist/fnode/index.D2kFuxXo.js +52 -0
- package/dist/fnode/index.D61MduW1.js +106 -0
- package/dist/fnode/index.Dd0lngp8.js +41 -0
- package/dist/fnode/index.DqwVukIB.js +52 -0
- package/dist/fnode/index.MWHLt6g3.js +52 -0
- package/dist/fnode/index.f798DPwo.js +93 -0
- package/dist/fnode/index.j5JP-zGw.js +52 -0
- package/dist/fnode/index.js +2784 -0
- package/package.json +3 -3
- package/dist/fnet/index.B5XE4ChJ.mjs +0 -1
- package/dist/fnet/index.Bfg4lyu-.mjs +0 -1
- package/dist/fnet/index.BoO2Mnox.mjs +0 -1
- package/dist/fnet/index.C7saWH6d.mjs +0 -1
- package/dist/fnet/index.CDct_kkF.mjs +0 -1
- package/dist/fnet/index.CMC8mlye.mjs +0 -1
- package/dist/fnet/index.CmMM-Ek9.mjs +0 -1
- package/dist/fnet/index.CzAV0S36.mjs +0 -1
- package/dist/fnet/index.D2N9YZmA.mjs +0 -1
- package/dist/fnet/index.DI3yyTtl.mjs +0 -1
- package/dist/fnet/index.DLGSTm8o.mjs +0 -1
- package/dist/fnet/index.Q-CYRcna.mjs +0 -1
- package/dist/fnet/index.TGA5BzMy.mjs +0 -1
- package/dist/fnet/index.UOds5XLl.mjs +0 -1
- package/dist/fnet/index.W6RYgypK.mjs +0 -1
- package/dist/fnet/index.dpz2QIRu.mjs +0 -1
- package/dist/fnet/index.mjs +0 -2
- package/dist/fnet/index.xd8c7XMr.mjs +0 -1
- package/dist/fnode/index.B5XE4ChJ.mjs +0 -1
- package/dist/fnode/index.Bfg4lyu-.mjs +0 -1
- package/dist/fnode/index.BoO2Mnox.mjs +0 -1
- package/dist/fnode/index.C7saWH6d.mjs +0 -1
- package/dist/fnode/index.CDct_kkF.mjs +0 -1
- package/dist/fnode/index.CMC8mlye.mjs +0 -1
- package/dist/fnode/index.CmMM-Ek9.mjs +0 -1
- package/dist/fnode/index.CzAV0S36.mjs +0 -1
- package/dist/fnode/index.D2N9YZmA.mjs +0 -1
- package/dist/fnode/index.DI3yyTtl.mjs +0 -1
- package/dist/fnode/index.DLGSTm8o.mjs +0 -1
- package/dist/fnode/index.DLs4zDM6.mjs +0 -1
- package/dist/fnode/index.Q-CYRcna.mjs +0 -1
- package/dist/fnode/index.UOds5XLl.mjs +0 -1
- package/dist/fnode/index.W6RYgypK.mjs +0 -1
- package/dist/fnode/index.dpz2QIRu.mjs +0 -1
- package/dist/fnode/index.mjs +0 -2
- package/dist/fnode/index.xd8c7XMr.mjs +0 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import fnetConfig from '@fnet/config';
|
|
2
|
+
import fnetDeployer from '@flownet/lib-to-docker';
|
|
3
|
+
import cloneDeep from 'lodash.clonedeep';
|
|
4
|
+
import semver from 'semver';
|
|
5
|
+
|
|
6
|
+
async function deployToDocker({
|
|
7
|
+
atom,
|
|
8
|
+
target,
|
|
9
|
+
onProgress,
|
|
10
|
+
projectDir,
|
|
11
|
+
dependencies,
|
|
12
|
+
context,
|
|
13
|
+
yamlTarget
|
|
14
|
+
}) {
|
|
15
|
+
|
|
16
|
+
const deployerName = 'docker';
|
|
17
|
+
|
|
18
|
+
if (onProgress) await onProgress({ message: `Deploying it as ${deployerName} package.` });
|
|
19
|
+
|
|
20
|
+
const config = target?.config ? await fnetConfig({
|
|
21
|
+
name: target.config,
|
|
22
|
+
dir: projectDir,
|
|
23
|
+
optional: true,
|
|
24
|
+
transferEnv: false,
|
|
25
|
+
tags: context.tags
|
|
26
|
+
}) : undefined;
|
|
27
|
+
|
|
28
|
+
const nextVersion = semver.inc(target.version || "0.1.0", "patch");
|
|
29
|
+
target.params.version = nextVersion; // TODO: remove this line
|
|
30
|
+
target.version = nextVersion;
|
|
31
|
+
yamlTarget.set('version', nextVersion);
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
const params = cloneDeep(target.params);
|
|
35
|
+
|
|
36
|
+
params.dependencies = cloneDeep(dependencies);
|
|
37
|
+
|
|
38
|
+
const args = {
|
|
39
|
+
atom,
|
|
40
|
+
params,
|
|
41
|
+
config: config?.config,
|
|
42
|
+
src: projectDir,
|
|
43
|
+
dest: projectDir,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const result = await fnetDeployer(args);
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
deployer: result,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { deployToDocker as default };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import semver from 'semver';
|
|
2
|
+
import fnetConfig from '@fnet/config';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import fnetShellJs from '@fnet/shelljs';
|
|
5
|
+
import FormData from 'form-data';
|
|
6
|
+
|
|
7
|
+
async function deployToFnetNode({ setProgress, context, deploymentProject, deploymentProjectTarget: target, yamlTarget }) {
|
|
8
|
+
|
|
9
|
+
await setProgress({ message: "Deploying it as fnet node." });
|
|
10
|
+
|
|
11
|
+
const { file: configFile, data: config } = await fnetConfig({
|
|
12
|
+
name: target.config || "fnet-node",
|
|
13
|
+
dir: context.project.projectDir,
|
|
14
|
+
tags: context.tags
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
if (!config.env.ATOM_API_URL) throw new Error(`ATOM_API_URL is required in ${configFile}`);
|
|
18
|
+
if (!config.env.ATOM_API_USERNAME) throw new Error(`ATOM_API_USERNAME is required in ${configFile}`);
|
|
19
|
+
if (!config.env.ATOM_API_PASSWORD) throw new Error(`ATOM_API_PASSWORD is required in ${configFile}`);
|
|
20
|
+
|
|
21
|
+
const apiTokenUrl = `${config.env.ATOM_API_URL}/v1/auth/token`;
|
|
22
|
+
const username = config.env.ATOM_API_USERNAME;
|
|
23
|
+
const password = config.env.ATOM_API_PASSWORD;
|
|
24
|
+
|
|
25
|
+
const tokenResponse = await fetch(apiTokenUrl, {
|
|
26
|
+
method: "POST",
|
|
27
|
+
headers: {
|
|
28
|
+
"Content-Type": "application/json"
|
|
29
|
+
},
|
|
30
|
+
body: JSON.stringify({ username, password })
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
if (!tokenResponse.ok) {
|
|
34
|
+
throw new Error(`Failed to fetch token: ${tokenResponse.statusText}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const tokenData = await tokenResponse.json();
|
|
38
|
+
const access_token = tokenData?.access_token;
|
|
39
|
+
|
|
40
|
+
if (!access_token) throw new Error(`Invalid access_token from ${apiTokenUrl}`);
|
|
41
|
+
|
|
42
|
+
deploymentProject.isDirty = true;
|
|
43
|
+
const newVersion = semver.inc(target.version, "patch");
|
|
44
|
+
target.params.version = newVersion; // TODO: remove this line
|
|
45
|
+
target.version = newVersion;
|
|
46
|
+
yamlTarget.set('version', newVersion);
|
|
47
|
+
|
|
48
|
+
const url = `${config.env.ATOM_API_URL}/v1/service/fnet-node/publish`;
|
|
49
|
+
|
|
50
|
+
const publishResponse = await fetch(url, {
|
|
51
|
+
method: "POST",
|
|
52
|
+
headers: {
|
|
53
|
+
"Content-Type": "application/json",
|
|
54
|
+
"Authorization": `Bearer ${access_token}`
|
|
55
|
+
},
|
|
56
|
+
body: JSON.stringify({
|
|
57
|
+
name: target.params.name,
|
|
58
|
+
version: target.params.version,
|
|
59
|
+
docs: target.params.docs,
|
|
60
|
+
configs: target.params.configs,
|
|
61
|
+
})
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (!publishResponse.ok) {
|
|
65
|
+
throw new Error(`Error publishing fnet node: ${publishResponse.statusText}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const publishData = await publishResponse.json();
|
|
69
|
+
|
|
70
|
+
if (publishData?.error) throw new Error('Error publishing fnet node.');
|
|
71
|
+
|
|
72
|
+
const upload_session_id = publishData?.upload.id;
|
|
73
|
+
|
|
74
|
+
let command = `fnet-dir-zipper`;
|
|
75
|
+
command += ` --sourceDir='${context.project.projectDir}'`;
|
|
76
|
+
command += ` --pattern=**/*`;
|
|
77
|
+
command += ` --stdout_format=json`;
|
|
78
|
+
|
|
79
|
+
const shResult = await fnetShellJs(command);
|
|
80
|
+
if (shResult.code !== 0) throw new Error(shResult.stderr);
|
|
81
|
+
|
|
82
|
+
const zipData = JSON.parse(shResult.stdout);
|
|
83
|
+
const zipFilePath = zipData.path;
|
|
84
|
+
|
|
85
|
+
let formData = new FormData();
|
|
86
|
+
formData.append('file', fs.createReadStream(zipFilePath));
|
|
87
|
+
|
|
88
|
+
const uploadResponse = await fetch(`${config.env.ATOM_API_URL}/v1/service/upload/single/${upload_session_id}`, {
|
|
89
|
+
method: 'POST',
|
|
90
|
+
headers: {
|
|
91
|
+
...formData.getHeaders(),
|
|
92
|
+
"Authorization": `Bearer ${access_token}`
|
|
93
|
+
},
|
|
94
|
+
body: formData
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
if (!uploadResponse.ok) {
|
|
98
|
+
throw new Error(`Error uploading fnet node: ${uploadResponse.statusText}`);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const uploadResult = await uploadResponse.json();
|
|
102
|
+
|
|
103
|
+
if (uploadResult?.error) throw new Error('Error uploading fnet node.');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export { deployToFnetNode as default };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import semver from 'semver';
|
|
4
|
+
import fnetShellJs from '@fnet/shelljs';
|
|
5
|
+
import fnetConfig from '@fnet/config';
|
|
6
|
+
import fnetUpListFiles from '@fnet/up-list-files';
|
|
7
|
+
import fnetObjectFromSchema from '@fnet/object-from-schema';
|
|
8
|
+
import yaml from 'yaml';
|
|
9
|
+
import { w as which } from './index.js';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
import 'child_process';
|
|
12
|
+
import '@fnet/prompt';
|
|
13
|
+
import 'commander';
|
|
14
|
+
import 'fs';
|
|
15
|
+
import '@fnet/yaml';
|
|
16
|
+
import '@fnet/shell-flow';
|
|
17
|
+
import '@flownet/lib-render-templates-dir';
|
|
18
|
+
import 'nunjucks';
|
|
19
|
+
import 'lodash.clonedeep';
|
|
20
|
+
import 'isobject';
|
|
21
|
+
import 'redis';
|
|
22
|
+
import '@flownet/lib-is-redis-online';
|
|
23
|
+
import 'node:crypto';
|
|
24
|
+
import '@flownet/lib-atom-api-js';
|
|
25
|
+
import 'lodash.merge';
|
|
26
|
+
import '@flownet/lib-parse-imports-js';
|
|
27
|
+
import '@fnet/npm-list-versions';
|
|
28
|
+
import '@fnet/npm-pick-versions';
|
|
29
|
+
import 'object-hash';
|
|
30
|
+
import 'ajv/dist/2020.js';
|
|
31
|
+
import 'ajv/dist/standalone/index.js';
|
|
32
|
+
import 'ajv-formats';
|
|
33
|
+
import 'path';
|
|
34
|
+
import '@flownet/lib-parse-node-url';
|
|
35
|
+
import 'bpmn-moddle';
|
|
36
|
+
import 'dagre';
|
|
37
|
+
import '@fnet/expression';
|
|
38
|
+
import 'chalk';
|
|
39
|
+
import '@fnet/list-files';
|
|
40
|
+
import '@fnet/key-value-transformer';
|
|
41
|
+
import 'lodash.pick';
|
|
42
|
+
import 'lodash.omit';
|
|
43
|
+
|
|
44
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
45
|
+
|
|
46
|
+
async function deployToNpm({ atom, setProgress, context, deploymentProject, deploymentProjectTarget: target, yamlTarget }) {
|
|
47
|
+
|
|
48
|
+
await setProgress({ message: "Deploying it as npm package." });
|
|
49
|
+
|
|
50
|
+
const projectDir = context.projectDir;
|
|
51
|
+
const packageJSONPath = path.resolve(projectDir, 'package.json');
|
|
52
|
+
|
|
53
|
+
const packageJSONContent = fs.readFileSync(packageJSONPath);
|
|
54
|
+
|
|
55
|
+
const packageJSON = JSON.parse(packageJSONContent);
|
|
56
|
+
|
|
57
|
+
packageJSON.name = target.params.name;
|
|
58
|
+
|
|
59
|
+
packageJSON.version = semver.inc(target.version, "patch");
|
|
60
|
+
|
|
61
|
+
const binName = target.params.bin?.name || target.params.bin;
|
|
62
|
+
const binEnabled = target.params.bin?.enabled !== false;
|
|
63
|
+
|
|
64
|
+
if (binEnabled && binName && typeof binName === 'string') {
|
|
65
|
+
packageJSON.bin = {
|
|
66
|
+
[binName]: 'dist/cli/esm/index.js'
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
delete packageJSON.scripts;
|
|
71
|
+
delete packageJSON.devDependencies;
|
|
72
|
+
|
|
73
|
+
packageJSON.scripts = {
|
|
74
|
+
"serve": "npx serve ."
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
fs.writeFileSync(packageJSONPath, JSON.stringify(packageJSON, null, "\t"));
|
|
78
|
+
|
|
79
|
+
// TODO: improve this for all builders/deploys
|
|
80
|
+
const configName = target.config || "npm";
|
|
81
|
+
let npmConfig = (await fnetConfig({ name: configName, dir: context.projectDir, tags: context.tags, optional: true }))?.data;
|
|
82
|
+
|
|
83
|
+
if (!npmConfig) {
|
|
84
|
+
// create config from schema
|
|
85
|
+
const schemas = fnetUpListFiles({ dir: __dirname, pattern: '@fnet/cli-project-schemas/dist/schemas/to-npm.yaml', absolute: true });
|
|
86
|
+
if (schemas.length === 0) throw new Error('Couldnt find schema to create npm config');
|
|
87
|
+
const newConfig = await fnetObjectFromSchema({ schema: schemas[0], tags: context.tags });
|
|
88
|
+
|
|
89
|
+
const projectDir = context.project.projectDir;
|
|
90
|
+
const dotFnetDir = path.resolve(projectDir, '.fnet');
|
|
91
|
+
if (!fs.existsSync(dotFnetDir)) fs.mkdirSync(dotFnetDir);
|
|
92
|
+
fs.writeFileSync(path.resolve(dotFnetDir, `${configName}.fnet`), yaml.stringify(newConfig));
|
|
93
|
+
npmConfig = newConfig;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
fs.writeFileSync(path.resolve(projectDir, '.npmrc'), `//registry.npmjs.org/:_authToken=${npmConfig.env.NPM_TOKEN}`);
|
|
97
|
+
|
|
98
|
+
if (target.dryRun === true) return;
|
|
99
|
+
|
|
100
|
+
const packageManager = which('bun') ? 'bun' : 'npm';
|
|
101
|
+
|
|
102
|
+
let result = await fnetShellJs(`${packageManager} publish --access public`, { cwd: projectDir });
|
|
103
|
+
if (result.code !== 0) throw new Error('Couldnt publish to npm');
|
|
104
|
+
|
|
105
|
+
// restore
|
|
106
|
+
fs.writeFileSync(packageJSONPath, packageJSONContent);
|
|
107
|
+
|
|
108
|
+
deploymentProject.isDirty = true;
|
|
109
|
+
|
|
110
|
+
target.version = packageJSON.version;
|
|
111
|
+
yamlTarget.set('version', packageJSON.version);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export { deployToNpm as default };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import semver from 'semver';
|
|
4
|
+
import fnetShellJs from '@fnet/shelljs';
|
|
5
|
+
import fnetConfig from '@fnet/config';
|
|
6
|
+
|
|
7
|
+
async function deployToGcs({ setProgress, context, deploymentProject, deploymentProjectTarget: target, registerToPackageManager, yamlTarget }) {
|
|
8
|
+
|
|
9
|
+
await setProgress({ message: "Deploying it as gcs package." });
|
|
10
|
+
|
|
11
|
+
const projectDir = context.projectDir;
|
|
12
|
+
const packageJSONPath = path.resolve(projectDir, 'package.json');
|
|
13
|
+
|
|
14
|
+
const packageJSONContent = fs.readFileSync(packageJSONPath);
|
|
15
|
+
|
|
16
|
+
const packageJSON = JSON.parse(packageJSONContent);
|
|
17
|
+
|
|
18
|
+
packageJSON.name = target.params.name;
|
|
19
|
+
packageJSON.version = semver.inc(target.version, "patch");
|
|
20
|
+
|
|
21
|
+
delete packageJSON.scripts;
|
|
22
|
+
delete packageJSON.devDependencies;
|
|
23
|
+
|
|
24
|
+
fs.writeFileSync(packageJSONPath, JSON.stringify(packageJSON, null, "\t"));
|
|
25
|
+
|
|
26
|
+
const { file: pmFile, data: gcsConfig } = await fnetConfig({
|
|
27
|
+
name: target.config || "gcs",
|
|
28
|
+
dir: context.projectDir,
|
|
29
|
+
tags: context.tags
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
let command = `fnet-files-to-gcs`;
|
|
33
|
+
command += ` --projectId='${gcsConfig.env.GCS_PROJECT_ID}'`;
|
|
34
|
+
command += ` --bucketName='${gcsConfig.env.GCS_BUCKET_NAME}'`;
|
|
35
|
+
command += ` --keyFilename='${path.resolve(path.dirname(pmFile), gcsConfig.env.GCS_UPLOADER_KEY_FILE)}'`;
|
|
36
|
+
command += ` --dir='${projectDir}'`;
|
|
37
|
+
command += ` --pattern={'dist/**/**','bin/**/**','test/**/**','*.html'}`;
|
|
38
|
+
command += ` --destDir='${packageJSON.name}/${packageJSON.version}'`;
|
|
39
|
+
command += ` --metadata.cacheControl='public, max-age=31536000, immutable'`;
|
|
40
|
+
// command += ` --verbose`;
|
|
41
|
+
|
|
42
|
+
if (gcsConfig.env.DOMAIN) command += ` --domain='${gcsConfig.env.DOMAIN}'`;
|
|
43
|
+
|
|
44
|
+
if (target.dry_run === true || target.params.dry_run === true) command += ` --dryRun`;
|
|
45
|
+
|
|
46
|
+
await fnetShellJs(command);
|
|
47
|
+
|
|
48
|
+
// restore
|
|
49
|
+
fs.writeFileSync(packageJSONPath, packageJSONContent);
|
|
50
|
+
|
|
51
|
+
if (target.dryRun === true) return;
|
|
52
|
+
|
|
53
|
+
deploymentProject.isDirty = true;
|
|
54
|
+
target.version = packageJSON.version;
|
|
55
|
+
yamlTarget.set('version', packageJSON.version);
|
|
56
|
+
|
|
57
|
+
await registerToPackageManager({ target, packageJSON });
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { deployToGcs as default };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import semver from 'semver';
|
|
2
|
+
import fnetConfig from '@fnet/config';
|
|
3
|
+
|
|
4
|
+
async function deployToFnetForm({ setProgress, context, deploymentProject, deploymentProjectTarget: target, yamlTarget }) {
|
|
5
|
+
|
|
6
|
+
await setProgress({ message: "Deploying it as fnet form." });
|
|
7
|
+
|
|
8
|
+
const { file: configFile, data: config } = await fnetConfig({
|
|
9
|
+
name: target.config || "fnet-form",
|
|
10
|
+
dir: context.projectDir,
|
|
11
|
+
tags: context.tags
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
if (!config.env.ATOM_API_URL) throw new Error(`ATOM_API_URL is required in ${configFile}`);
|
|
15
|
+
if (!config.env.ATOM_API_USERNAME) throw new Error(`ATOM_API_USERNAME is required in ${configFile}`);
|
|
16
|
+
if (!config.env.ATOM_API_PASSWORD) throw new Error(`ATOM_API_PASSWORD is required in ${configFile}`);
|
|
17
|
+
|
|
18
|
+
const apiTokenUrl = `${config.env.ATOM_API_URL}/v1/auth/token`;
|
|
19
|
+
const username = config.env.ATOM_API_USERNAME;
|
|
20
|
+
const password = config.env.ATOM_API_PASSWORD;
|
|
21
|
+
|
|
22
|
+
const tokenResponse = await fetch(apiTokenUrl, {
|
|
23
|
+
method: "POST",
|
|
24
|
+
headers: {
|
|
25
|
+
"Content-Type": "application/json"
|
|
26
|
+
},
|
|
27
|
+
body: JSON.stringify({ username, password })
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
if (!tokenResponse.ok) {
|
|
31
|
+
throw new Error(`Failed to fetch token: ${tokenResponse.statusText}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const tokenData = await tokenResponse.json();
|
|
35
|
+
const access_token = tokenData?.access_token;
|
|
36
|
+
|
|
37
|
+
if (!access_token) throw new Error(`Invalid access_token from ${apiTokenUrl}`);
|
|
38
|
+
|
|
39
|
+
deploymentProject.isDirty = true;
|
|
40
|
+
|
|
41
|
+
const newVersion = semver.inc(target.version, "patch");
|
|
42
|
+
target.params.version = newVersion; // TODO: remove this line
|
|
43
|
+
target.version = newVersion;
|
|
44
|
+
yamlTarget.set('version', newVersion);
|
|
45
|
+
const url = `${config.env.ATOM_API_URL}/v1/service/fnet-form/publish`;
|
|
46
|
+
|
|
47
|
+
const publishResponse = await fetch(url, {
|
|
48
|
+
method: "POST",
|
|
49
|
+
headers: {
|
|
50
|
+
"Content-Type": "application/json",
|
|
51
|
+
"Authorization": `Bearer ${access_token}`
|
|
52
|
+
},
|
|
53
|
+
body: JSON.stringify({
|
|
54
|
+
name: target.params.name,
|
|
55
|
+
version: target.params.version,
|
|
56
|
+
docs: target.params.docs,
|
|
57
|
+
configs: target.params.configs,
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
if (!publishResponse.ok) {
|
|
62
|
+
throw new Error(`Error publishing fnet form: ${publishResponse.statusText}`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const publishData = await publishResponse.json();
|
|
66
|
+
|
|
67
|
+
if (publishData?.error) throw new Error('Error publishing fnet form.');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { deployToFnetForm as default };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import fnetConfig from '@fnet/config';
|
|
2
|
+
import fnetDeploy from '@fnet/to-rust';
|
|
3
|
+
import cloneDeep from 'lodash.clonedeep';
|
|
4
|
+
import semver from 'semver';
|
|
5
|
+
|
|
6
|
+
async function deployToRust({
|
|
7
|
+
atom,
|
|
8
|
+
target,
|
|
9
|
+
onProgress,
|
|
10
|
+
projectDir,
|
|
11
|
+
dependencies,
|
|
12
|
+
context,
|
|
13
|
+
yamlTarget
|
|
14
|
+
}) {
|
|
15
|
+
|
|
16
|
+
const deployerName = 'Rust';
|
|
17
|
+
|
|
18
|
+
if (onProgress) await onProgress({ message: `Deploying it as ${deployerName} package.` });
|
|
19
|
+
|
|
20
|
+
const config = target?.config ? await fnetConfig({
|
|
21
|
+
name: target.config,
|
|
22
|
+
dir: projectDir,
|
|
23
|
+
optional: true,
|
|
24
|
+
transferEnv:false,
|
|
25
|
+
tags: context.tags
|
|
26
|
+
}) : undefined;
|
|
27
|
+
|
|
28
|
+
const nextVersion = semver.inc(target.version || "0.1.0", "patch");
|
|
29
|
+
target.params.version = nextVersion; // TODO: remove this line
|
|
30
|
+
target.version = nextVersion;
|
|
31
|
+
yamlTarget.set('version', nextVersion);
|
|
32
|
+
|
|
33
|
+
const params = cloneDeep(target.params);
|
|
34
|
+
|
|
35
|
+
params.dependencies = cloneDeep(dependencies);
|
|
36
|
+
|
|
37
|
+
const args = {
|
|
38
|
+
atom,
|
|
39
|
+
params,
|
|
40
|
+
config: config?.config,
|
|
41
|
+
src: projectDir,
|
|
42
|
+
dest: projectDir,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const result = await fnetDeploy(args);
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
deployer: result,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { deployToRust as default };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import semver from 'semver';
|
|
4
|
+
import fnetShellJs from '@fnet/shelljs';
|
|
5
|
+
import fnetConfig from '@fnet/config';
|
|
6
|
+
|
|
7
|
+
async function deployToFnetPackage({ setProgress, context, deploymentProject, deploymentProjectTarget: target, yamlTarget }) {
|
|
8
|
+
|
|
9
|
+
await setProgress({ message: "Deploying it as fnet package." });
|
|
10
|
+
|
|
11
|
+
const projectDir = context.projectDir;
|
|
12
|
+
const packageJSONPath = path.resolve(projectDir, 'package.json');
|
|
13
|
+
|
|
14
|
+
const packageJSONContent = fs.readFileSync(packageJSONPath);
|
|
15
|
+
|
|
16
|
+
const packageJSON = JSON.parse(packageJSONContent);
|
|
17
|
+
|
|
18
|
+
packageJSON.name = target.params.name;
|
|
19
|
+
packageJSON.version = semver.inc(target.version, "patch");
|
|
20
|
+
|
|
21
|
+
delete packageJSON.scripts;
|
|
22
|
+
delete packageJSON.devDependencies;
|
|
23
|
+
|
|
24
|
+
fs.writeFileSync(packageJSONPath, JSON.stringify(packageJSON, null, "\t"));
|
|
25
|
+
|
|
26
|
+
const { file: configFile, data: config } = await fnetConfig({
|
|
27
|
+
name: target.config || "fnet-package",
|
|
28
|
+
dir: context.projectDir,
|
|
29
|
+
tags: context.tags
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
if (!config.env.ATOM_API_URL) throw new Error(`ATOM_API_URL is required in ${configFile}`);
|
|
34
|
+
if (!config.env.ATOM_API_USERNAME) throw new Error(`ATOM_API_USERNAME is required in ${configFile}`);
|
|
35
|
+
if (!config.env.ATOM_API_PASSWORD) throw new Error(`ATOM_API_PASSWORD is required in ${configFile}`);
|
|
36
|
+
|
|
37
|
+
const apiUrl = `${config.env.ATOM_API_URL}/v1/auth/token`;
|
|
38
|
+
const username = config.env.ATOM_API_USERNAME;
|
|
39
|
+
const password = config.env.ATOM_API_PASSWORD;
|
|
40
|
+
|
|
41
|
+
const tokenResponse = await fetch(apiUrl, {
|
|
42
|
+
method: "POST",
|
|
43
|
+
headers: {
|
|
44
|
+
"Content-Type": "application/json"
|
|
45
|
+
},
|
|
46
|
+
body: JSON.stringify({ username, password })
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
if (!tokenResponse.ok) {
|
|
50
|
+
throw new Error(`Failed to fetch token: ${tokenResponse.statusText}`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const tokenData = await tokenResponse.json();
|
|
54
|
+
const access_token = tokenData?.access_token;
|
|
55
|
+
if (!access_token) throw new Error(`Invalid access_token from ${apiUrl}`);
|
|
56
|
+
|
|
57
|
+
let command = `fnet-files-to-gcs`;
|
|
58
|
+
command += ` --projectId='${config.env.GCS_PROJECT_ID}'`;
|
|
59
|
+
command += ` --bucketName='${config.env.GCS_BUCKET_NAME}'`;
|
|
60
|
+
command += ` --keyFilename='${path.resolve(path.dirname(configFile), config.env.GCS_UPLOADER_KEY_FILE)}'`;
|
|
61
|
+
command += ` --dir='${projectDir}'`;
|
|
62
|
+
command += ` --pattern={'dist/**/**','bin/**/**','test/**/**','*.html'}`;
|
|
63
|
+
command += ` --destDir='${packageJSON.name}/${packageJSON.version}'`;
|
|
64
|
+
command += ` --metadata.cacheControl='public, max-age=31536000, immutable'`;
|
|
65
|
+
// command += ` --verbose`;
|
|
66
|
+
|
|
67
|
+
if (config.env.DOMAIN) command += ` --domain='${config.env.DOMAIN}'`;
|
|
68
|
+
|
|
69
|
+
if (target.dry_run === true || target.params.dry_run === true) command += ` --dryRun`;
|
|
70
|
+
|
|
71
|
+
await fnetShellJs(command);
|
|
72
|
+
|
|
73
|
+
// restore
|
|
74
|
+
fs.writeFileSync(packageJSONPath, packageJSONContent);
|
|
75
|
+
|
|
76
|
+
if (target.dryRun === true) return;
|
|
77
|
+
|
|
78
|
+
deploymentProject.isDirty = true;
|
|
79
|
+
target.version = packageJSON.version;
|
|
80
|
+
yamlTarget.set('version', packageJSON.version);
|
|
81
|
+
|
|
82
|
+
const url = `${config.env.ATOM_API_URL}/v1/service/fnet-package/publish`;
|
|
83
|
+
const publishResponse = await fetch(url, {
|
|
84
|
+
method: "POST",
|
|
85
|
+
headers: {
|
|
86
|
+
"Content-Type": "application/json",
|
|
87
|
+
"Authorization": `Bearer ${access_token}`
|
|
88
|
+
},
|
|
89
|
+
body: JSON.stringify({
|
|
90
|
+
name: packageJSON.name,
|
|
91
|
+
version: packageJSON.version,
|
|
92
|
+
version_domain: config.env.DOMAIN,
|
|
93
|
+
docs: target.params.docs,
|
|
94
|
+
configs: target.params.configs,
|
|
95
|
+
})
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
if (!publishResponse.ok) {
|
|
99
|
+
throw new Error(`Failed to publish fnet package: ${publishResponse.statusText}`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const publishData = await publishResponse.json();
|
|
103
|
+
if (publishData?.error) throw new Error("Failed to publish fnet package.");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export { deployToFnetPackage as default };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import fnetConfig from '@fnet/config';
|
|
2
|
+
import fnetToElectron from '@flownet/lib-to-electron';
|
|
3
|
+
import cloneDeep from 'lodash.clonedeep';
|
|
4
|
+
import semver from 'semver';
|
|
5
|
+
|
|
6
|
+
async function deployToElectron({
|
|
7
|
+
atom,
|
|
8
|
+
target,
|
|
9
|
+
onProgress,
|
|
10
|
+
projectDir,
|
|
11
|
+
dependencies,
|
|
12
|
+
context,
|
|
13
|
+
yamlTarget
|
|
14
|
+
}) {
|
|
15
|
+
|
|
16
|
+
const deployerName = 'electron';
|
|
17
|
+
|
|
18
|
+
if (onProgress) await onProgress({ message: `Deploying it as ${deployerName} package.` });
|
|
19
|
+
|
|
20
|
+
const config = target?.config ? await fnetConfig({
|
|
21
|
+
name: target.config,
|
|
22
|
+
dir: projectDir,
|
|
23
|
+
optional: true,
|
|
24
|
+
transferEnv:false,
|
|
25
|
+
tags: context.tags
|
|
26
|
+
}) : undefined;
|
|
27
|
+
|
|
28
|
+
const nextVersion = semver.inc(target.version || "0.1.0", "patch");
|
|
29
|
+
target.version = nextVersion;
|
|
30
|
+
yamlTarget.set('version', nextVersion);
|
|
31
|
+
|
|
32
|
+
const params = cloneDeep(target.params);
|
|
33
|
+
|
|
34
|
+
params.dependencies = cloneDeep(dependencies);
|
|
35
|
+
|
|
36
|
+
const args = {
|
|
37
|
+
atom,
|
|
38
|
+
params,
|
|
39
|
+
config: config?.config,
|
|
40
|
+
src: projectDir,
|
|
41
|
+
dest: projectDir,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const result = await fnetToElectron(args);
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
deployer: result,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { deployToElectron as default };
|