@fnet/cli 0.101.0 → 0.101.2

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 (71) hide show
  1. package/dist/fnet/index.B5XE4ChJ.js +1 -0
  2. package/dist/fnet/index.Bfg4lyu-.js +1 -0
  3. package/dist/fnet/index.BoO2Mnox.js +1 -0
  4. package/dist/fnet/index.C7saWH6d.js +1 -0
  5. package/dist/fnet/index.CDct_kkF.js +1 -0
  6. package/dist/fnet/index.CMC8mlye.js +1 -0
  7. package/dist/fnet/index.CmMM-Ek9.js +1 -0
  8. package/dist/fnet/index.CzAV0S36.js +1 -0
  9. package/dist/fnet/index.D2N9YZmA.js +1 -0
  10. package/dist/fnet/index.DI3yyTtl.js +1 -0
  11. package/dist/fnet/index.DLGSTm8o.js +1 -0
  12. package/dist/fnet/index.Q-CYRcna.js +1 -0
  13. package/dist/fnet/index.Rl3XkXvK.js +1 -0
  14. package/dist/fnet/index.UOds5XLl.js +1 -0
  15. package/dist/fnet/index.W6RYgypK.js +1 -0
  16. package/dist/fnet/index.dpz2QIRu.js +1 -0
  17. package/dist/fnet/index.js +1 -4561
  18. package/dist/fnet/index.xd8c7XMr.js +1 -0
  19. package/dist/fnode/index.B5XE4ChJ.js +1 -0
  20. package/dist/fnode/index.Bfg4lyu-.js +1 -0
  21. package/dist/fnode/index.BoO2Mnox.js +1 -0
  22. package/dist/fnode/index.C7saWH6d.js +1 -0
  23. package/dist/fnode/index.CDct_kkF.js +1 -0
  24. package/dist/fnode/index.CMC8mlye.js +1 -0
  25. package/dist/fnode/index.CmMM-Ek9.js +1 -0
  26. package/dist/fnode/index.Cr2Vp1gC.js +1 -0
  27. package/dist/fnode/index.CzAV0S36.js +1 -0
  28. package/dist/fnode/index.D2N9YZmA.js +1 -0
  29. package/dist/fnode/index.DI3yyTtl.js +1 -0
  30. package/dist/fnode/index.DLGSTm8o.js +1 -0
  31. package/dist/fnode/index.Q-CYRcna.js +1 -0
  32. package/dist/fnode/index.UOds5XLl.js +1 -0
  33. package/dist/fnode/index.W6RYgypK.js +1 -0
  34. package/dist/fnode/index.dpz2QIRu.js +1 -0
  35. package/dist/fnode/index.js +1 -2783
  36. package/dist/fnode/index.xd8c7XMr.js +1 -0
  37. package/package.json +3 -3
  38. package/dist/fnet/index.B5vpZn1Z.js +0 -53
  39. package/dist/fnet/index.B6WHm9H0.js +0 -106
  40. package/dist/fnet/index.B90Vm9uq.js +0 -114
  41. package/dist/fnet/index.BMsD46br.js +0 -60
  42. package/dist/fnet/index.BUhoGq-h.js +0 -70
  43. package/dist/fnet/index.BjzEMdm1.js +0 -52
  44. package/dist/fnet/index.C9zKEF61.js +0 -106
  45. package/dist/fnet/index.CQNYMi1Z.js +0 -51
  46. package/dist/fnet/index.CX8eMqfH.js +0 -191
  47. package/dist/fnet/index.Ce8sTnt_.js +0 -52
  48. package/dist/fnet/index.D2kFuxXo.js +0 -52
  49. package/dist/fnet/index.D61MduW1.js +0 -106
  50. package/dist/fnet/index.Dd0lngp8.js +0 -41
  51. package/dist/fnet/index.DqwVukIB.js +0 -52
  52. package/dist/fnet/index.MWHLt6g3.js +0 -52
  53. package/dist/fnet/index.f798DPwo.js +0 -93
  54. package/dist/fnet/index.j5JP-zGw.js +0 -52
  55. package/dist/fnode/index.B5vpZn1Z.js +0 -53
  56. package/dist/fnode/index.B6WHm9H0.js +0 -106
  57. package/dist/fnode/index.BMsD46br.js +0 -60
  58. package/dist/fnode/index.BNSTS5o6.js +0 -109
  59. package/dist/fnode/index.BUhoGq-h.js +0 -70
  60. package/dist/fnode/index.BjzEMdm1.js +0 -52
  61. package/dist/fnode/index.C9zKEF61.js +0 -106
  62. package/dist/fnode/index.CQNYMi1Z.js +0 -51
  63. package/dist/fnode/index.CX8eMqfH.js +0 -191
  64. package/dist/fnode/index.Ce8sTnt_.js +0 -52
  65. package/dist/fnode/index.D2kFuxXo.js +0 -52
  66. package/dist/fnode/index.D61MduW1.js +0 -106
  67. package/dist/fnode/index.Dd0lngp8.js +0 -41
  68. package/dist/fnode/index.DqwVukIB.js +0 -52
  69. package/dist/fnode/index.MWHLt6g3.js +0 -52
  70. package/dist/fnode/index.f798DPwo.js +0 -93
  71. package/dist/fnode/index.j5JP-zGw.js +0 -52
@@ -1,53 +0,0 @@
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 };
@@ -1,106 +0,0 @@
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 };
@@ -1,60 +0,0 @@
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 };
@@ -1,109 +0,0 @@
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 'path';
12
- import 'child_process';
13
- import '@fnet/prompt';
14
- import 'commander';
15
- import 'fs';
16
- import 'os';
17
- import '@fnet/yaml';
18
- import '@fnet/shell-flow';
19
- import '@flownet/lib-render-templates-dir';
20
- import 'node:os';
21
- import 'nunjucks';
22
- import 'node:crypto';
23
- import '@flownet/lib-atom-api-js';
24
- import '@flownet/lib-parse-node-url';
25
- import '@flownet/lib-parse-imports-js';
26
- import '@fnet/list-files';
27
- import 'chalk';
28
- import 'redis';
29
- import '@flownet/lib-is-redis-online';
30
- import 'lodash.merge';
31
- import '@fnet/npm-list-versions';
32
- import '@fnet/npm-pick-versions';
33
- import 'object-hash';
34
- import 'ajv/dist/2020.js';
35
- import 'ajv/dist/standalone/index.js';
36
- import 'ajv-formats';
37
- import '@fnet/auto-conda-env';
38
-
39
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
40
-
41
- async function deployToNpm({ atom, setProgress, context, deploymentProject, deploymentProjectTarget: target, yamlTarget }) {
42
-
43
- await setProgress({ message: "Deploying it as npm package." });
44
-
45
- const projectDir = context.projectDir;
46
- const packageJSONPath = path.resolve(projectDir, 'package.json');
47
-
48
- const packageJSONContent = fs.readFileSync(packageJSONPath);
49
-
50
- const packageJSON = JSON.parse(packageJSONContent);
51
-
52
- packageJSON.name = target.params.name;
53
-
54
- packageJSON.version = semver.inc(target.version, "patch");
55
-
56
- const binName = target.params.bin?.name || target.params.bin;
57
- const binEnabled = target.params.bin?.enabled !== false;
58
-
59
- if (binEnabled && binName && typeof binName === 'string') {
60
- packageJSON.bin = {
61
- [binName]: 'dist/cli/esm/index.js'
62
- };
63
- }
64
-
65
- delete packageJSON.scripts;
66
- delete packageJSON.devDependencies;
67
-
68
- packageJSON.scripts = {
69
- "serve": "npx serve ."
70
- };
71
-
72
- fs.writeFileSync(packageJSONPath, JSON.stringify(packageJSON, null, "\t"));
73
-
74
- // TODO: improve this for all builders/deploys
75
- const configName = target.config || "npm";
76
- let npmConfig = (await fnetConfig({ name: configName, dir: context.projectDir, tags: context.tags, optional: true }))?.data;
77
-
78
- if (!npmConfig) {
79
- // create config from schema
80
- const schemas = fnetUpListFiles({ dir: __dirname, pattern: '@fnet/cli-project-schemas/dist/schemas/to-npm.yaml', absolute: true });
81
- if (schemas.length === 0) throw new Error('Couldnt find schema to create npm config');
82
- const newConfig = await fnetObjectFromSchema({ schema: schemas[0], tags: context.tags });
83
-
84
- const projectDir = context.project.projectDir;
85
- const dotFnetDir = path.resolve(projectDir, '.fnet');
86
- if (!fs.existsSync(dotFnetDir)) fs.mkdirSync(dotFnetDir);
87
- fs.writeFileSync(path.resolve(dotFnetDir, `${configName}.fnet`), yaml.stringify(newConfig));
88
- npmConfig = newConfig;
89
- }
90
-
91
- fs.writeFileSync(path.resolve(projectDir, '.npmrc'), `//registry.npmjs.org/:_authToken=${npmConfig.env.NPM_TOKEN}`);
92
-
93
- if (target.dryRun === true) return;
94
-
95
- const packageManager = which('bun') ? 'bun' : 'npm';
96
-
97
- let result = await fnetShellJs(`${packageManager} publish --access public`, { cwd: projectDir });
98
- if (result.code !== 0) throw new Error('Couldnt publish to npm');
99
-
100
- // restore
101
- fs.writeFileSync(packageJSONPath, packageJSONContent);
102
-
103
- deploymentProject.isDirty = true;
104
-
105
- target.version = packageJSON.version;
106
- yamlTarget.set('version', packageJSON.version);
107
- }
108
-
109
- export { deployToNpm as default };
@@ -1,70 +0,0 @@
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 };
@@ -1,52 +0,0 @@
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 };
@@ -1,106 +0,0 @@
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 };
@@ -1,51 +0,0 @@
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 };