@ptkl/toolkit 0.3.0 → 0.4.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.
@@ -3,12 +3,12 @@ import { Command } from "commander";
3
3
  import { commands } from "../commands/index.js";
4
4
  const program = new Command();
5
5
  commands.forEach(c => program.addCommand(c));
6
- program.parseAsync(process.argv).catch((err) => {
6
+ program.parseAsync(process.argv);
7
+ process.on('uncaughtException', (err) => {
7
8
  const { response } = err;
8
9
  if (response && response.data) {
9
10
  console.error(response.data.message);
10
- console.log(response);
11
11
  return;
12
12
  }
13
- console.error(err.message);
13
+ process.exit(1);
14
14
  });
@@ -1,6 +1,6 @@
1
1
  import { Command } from "commander";
2
2
  import util from "../lib/util.js";
3
- import Api from "protokol-sdk";
3
+ import Api from "@ptkl/sdk";
4
4
  import OutputFormatCommand from "./outputCommand.js";
5
5
  class ApiUsersCommand {
6
6
  register() {
@@ -17,13 +17,10 @@ class ApiUsersCommand {
17
17
  .description("Retrieve an auth token for an API user")
18
18
  .requiredOption("-u, --user <user>", "Username or name of the API user")
19
19
  .requiredOption("-p, --password <password>", "Password or secret for the API user")).action(this.getAuthToken))
20
- // .addCommand( new OutputFormatCommand(
21
- // new Command("edit")
22
- // .description("edit API user")
23
- // .requiredOption("-u, --uuid <uuid>", "UUID of the API user")
24
- // .requiredOption("-r, --roles <roles...>", "list of role uuids")
25
- // ).action(this.edit)
26
- // )
20
+ .addCommand(new OutputFormatCommand(new Command("edit")
21
+ .description("edit API user")
22
+ .requiredOption("-u, --uuid <uuid>", "UUID of the API user")
23
+ .requiredOption("-r, --roles <roles...>", "list of role uuids")).action(this.edit))
27
24
  .addCommand(new OutputFormatCommand(new Command("list").description("list all API user's")).action(this.list))
28
25
  .addCommand(new OutputFormatCommand(new Command("get")
29
26
  .description("Retrieve an API user by UUID")
@@ -32,41 +29,41 @@ class ApiUsersCommand {
32
29
  async newSecret(opts) {
33
30
  const { uuid } = opts;
34
31
  const profile = util.getCurrentProfile();
35
- const client = new Api({ project: profile.project, token: profile.token, host: profile.host }).apiUser();
32
+ const client = new Api({ token: profile.token, host: profile.host }).apiUser();
36
33
  const secret = await client.newSecret(uuid);
37
34
  return secret;
38
35
  }
39
36
  async revokeSecret(opts) {
40
37
  const { uuid } = opts;
41
38
  const profile = util.getCurrentProfile();
42
- const client = new Api({ project: profile.project, token: profile.token, host: profile.host }).apiUser();
39
+ const client = new Api({ token: profile.token, host: profile.host }).apiUser();
43
40
  const status = await client.revokeSecret(uuid);
44
41
  return status;
45
42
  }
46
43
  async getAuthToken(opts) {
47
44
  const { user, password } = opts;
48
45
  const profile = util.getCurrentProfile();
49
- const client = new Api({ project: profile.project, token: profile.token, host: profile.host }).apiUser();
50
- const auth = await client.apiAuth(user, password);
46
+ const client = new Api({ token: profile.token, host: profile.host }).apiUser();
47
+ const auth = await client.auth(user, password);
51
48
  return auth.data.Token;
52
49
  }
53
50
  async edit(opts) {
54
51
  const { uuid, roles } = opts;
55
52
  const profile = util.getCurrentProfile();
56
- const client = new Api({ project: profile.project, token: profile.token, host: profile.host }).apiUser();
53
+ const client = new Api({ token: profile.token, host: profile.host }).apiUser();
57
54
  const updatedUser = await client.edit(uuid, roles);
58
55
  return updatedUser;
59
56
  }
60
57
  async list() {
61
58
  const profile = util.getCurrentProfile();
62
- const client = new Api({ project: profile.project, token: profile.token, host: profile.host }).apiUser();
59
+ const client = new Api({ token: profile.token, host: profile.host }).apiUser();
63
60
  const users = await client.list();
64
61
  return users;
65
62
  }
66
63
  async get(opts) {
67
64
  const { uuid } = opts;
68
65
  const profile = util.getCurrentProfile();
69
- const client = new Api({ project: profile.project, token: profile.token, host: profile.host }).apiUser();
66
+ const client = new Api({ token: profile.token, host: profile.host }).apiUser();
70
67
  const user = await client.get(uuid);
71
68
  return user;
72
69
  }
@@ -1,6 +1,6 @@
1
1
  import { Command, Option } from "commander";
2
2
  import util from "../lib/util.js";
3
- import Api from "protokol-sdk";
3
+ import Api from "@ptkl/sdk";
4
4
  import { build, createServer } from 'vite';
5
5
  import { c } from 'tar';
6
6
  import { Writable } from "stream";
@@ -8,6 +8,9 @@ import { writeFileSync } from "fs";
8
8
  import Util from "../lib/util.js";
9
9
  import Playground from "../playground.js";
10
10
  import { join } from 'path';
11
+ /**
12
+ * Deprecation notice: Apps as such will be deprecated in favor for Protokol Forge and this will be removed in the future.
13
+ */
11
14
  class AppsCommand {
12
15
  register() {
13
16
  return new Command("apps")
@@ -67,26 +70,26 @@ class AppsCommand {
67
70
  async download(options) {
68
71
  const { apptype, version, ref, output } = options;
69
72
  const profile = util.getCurrentProfile();
70
- const client = new Api({ project: profile.project, token: profile.token, host: profile.host }).app(apptype);
73
+ const client = new Api({ token: profile.token, host: profile.host }).app(apptype);
71
74
  return await client.download(version, ref, output);
72
75
  }
73
76
  async upload(options) {
74
77
  const { apptype, directory, build } = options;
75
78
  const profile = util.getCurrentProfile();
76
- const client = new Api({ project: profile.project, token: profile.token, host: profile.host }).app(apptype);
79
+ const client = new Api({ token: profile.token, host: profile.host }).app(apptype);
77
80
  return await client.upload(directory, build);
78
81
  }
79
82
  async deploy(options) {
80
83
  const { apptype, dev_version, public_version, ref } = options;
81
84
  const profile = util.getCurrentProfile();
82
- const client = new Api({ project: profile.project, token: profile.token, host: profile.host }).app(apptype);
85
+ const client = new Api({ token: profile.token, host: profile.host }).app(apptype);
83
86
  return await client.updateSettings({ dev_version, public_version }, ref);
84
87
  }
85
88
  async playground(options) {
86
89
  let { path, port, sdk_version, engine, apptype } = options;
87
90
  port = port ? Number(port) : 11400;
88
91
  const profile = util.getCurrentProfile();
89
- const client = new Api({ project: profile.project, token: profile.token, host: profile.host }).app();
92
+ const client = new Api({ token: profile.token, host: profile.host }).app();
90
93
  let playgroundWatcher = new Playground(apptype, path, Number(sdk_version), engine, port, profile);
91
94
  await playgroundWatcher.init();
92
95
  playgroundWatcher.start();
@@ -0,0 +1,88 @@
1
+ import { Command } from "commander";
2
+ import Builder from "../builder/index.js";
3
+ import { WebSocketServer } from "ws";
4
+ import { resolve } from "path";
5
+ import { rollup } from "rollup";
6
+ import util from "../lib/util.js";
7
+ import Api from "@ptkl/sdk";
8
+ class ComponentCommand {
9
+ register() {
10
+ return new Command("component")
11
+ .description("Manage components")
12
+ .version("0.1.0")
13
+ .addCommand(new Command("builder")
14
+ .description("Run builder for component templates")
15
+ .requiredOption("-v, --version <version>", "SDK version to be used for build", "6")
16
+ .requiredOption("-e, --engine <engine>", "SDK engine to be used for build", "react")
17
+ .action(this.builder))
18
+ .addCommand(new Command("build")
19
+ .description("Build templates for component")
20
+ .requiredOption("-p, --path <path>", "Path to the source files", "./")
21
+ .action(this.build));
22
+ }
23
+ async builder(options) {
24
+ const { version, engine } = options;
25
+ console.log(`Running builder for SDK version ${version} with engine ${engine}`);
26
+ const ws = new WebSocketServer({ port: 11400 });
27
+ ws.on('connection', (socket) => {
28
+ socket.on('message', async (message) => {
29
+ console.log("Building component templates...");
30
+ const nodes = JSON.parse(message.toString());
31
+ try {
32
+ let dist = null;
33
+ if (version === '5') {
34
+ const builder = new Builder(5, "vue2");
35
+ const compiledFiles = await builder.buildFromNodes(nodes);
36
+ dist = Object.assign({}, compiledFiles);
37
+ }
38
+ socket.send(JSON.stringify({ dist }));
39
+ console.log('Component templates built successfully');
40
+ // Do something with the parsed JSON
41
+ }
42
+ catch (error) { // Bad Request
43
+ socket.send(JSON.stringify({ error: error.message }));
44
+ console.error(error.message);
45
+ }
46
+ });
47
+ });
48
+ }
49
+ async build(options) {
50
+ try {
51
+ const { path } = options;
52
+ const configPath = resolve(path, 'ptkl.config.js');
53
+ console.log(`Loading config from ${configPath}`);
54
+ const { default: config } = await import(configPath);
55
+ const { name, version, input, engine, rollupOptions } = config;
56
+ const inputPath = resolve(path, input);
57
+ const outputOptions = {
58
+ format: 'esm',
59
+ name,
60
+ };
61
+ process.chdir(path);
62
+ const bundle = await rollup({
63
+ input: inputPath,
64
+ ...rollupOptions,
65
+ output: outputOptions,
66
+ });
67
+ const { output } = await bundle.generate(outputOptions);
68
+ console.log(`Bundle generated with size ${output[0].code.length} bytes`);
69
+ const profile = util.getCurrentProfile();
70
+ const client = new Api({ token: profile.token, host: profile.host }).component(name);
71
+ const d = output.reduce((curr, next) => {
72
+ if (next.isEntry) {
73
+ return {
74
+ ...curr,
75
+ [next.fileName]: next.code
76
+ };
77
+ }
78
+ }, {});
79
+ await client.saveTemplatesDist(version, 6, engine, d);
80
+ console.log(`Component templates saved successfully`);
81
+ }
82
+ catch (error) {
83
+ console.error(error);
84
+ return;
85
+ }
86
+ }
87
+ }
88
+ export default new ComponentCommand();
@@ -15,15 +15,23 @@ class ForgeCommand {
15
15
  .requiredOption("-p, --path <path>", "Path is directory where app is located.")
16
16
  .option("-u, --upload", "Upload bundle")
17
17
  .action(this.bundle))
18
+ .addCommand(new Command("remove-version")
19
+ .description("Remove version of app")
20
+ .requiredOption("-r, --ref <ref>", "App reference (e.g., uuid or name)")
21
+ .requiredOption("-v, --version <version>", "Version of the app to remove")
22
+ .action(this.removeVersion))
18
23
  .addCommand(new Command("dev")
19
24
  .description("Run dev app")
20
25
  .requiredOption("-p, --path <path>", "Path is directory where app is located.")
21
- .action(this.runDev));
26
+ .action(this.runDev))
27
+ .addCommand(new Command("list")
28
+ .description("List all available apps")
29
+ .action(this.listApps));
22
30
  }
23
31
  async bundle(options) {
24
32
  const { path, upload } = options;
25
33
  const module = await import(`${path}/ptkl.config.js`);
26
- const { views, name, version, distPath, icon, label, permissions, } = module.default ?? {};
34
+ const { views, name, version, distPath, icon, type, label, permissions, } = module.default ?? {};
27
35
  // build manifest file
28
36
  const manifest = {
29
37
  name,
@@ -32,12 +40,12 @@ class ForgeCommand {
32
40
  label,
33
41
  icon,
34
42
  permissions,
43
+ type: type || 'platform', // default to 'platform' if not specified
35
44
  };
36
- const profile = Util.getCurrentProfile();
37
45
  const client = Util.getClientForProfile();
38
46
  // get base url of the platform client
39
47
  const baseUrl = client.getPlatformBaseURL();
40
- const base = `${baseUrl}/v3/system/gateway/app-service/forge/static/bundle/${profile.project}/${name}/${version}`;
48
+ const base = `${baseUrl}/luma/appservice/v1/forge/static/bundle/${name}/${version}`;
41
49
  manifest.icon = `${base}/${icon}`;
42
50
  const buildViews = Object.keys(views).map((view) => {
43
51
  manifest.views[view] = `${view}.bundle.js`;
@@ -48,16 +56,17 @@ class ForgeCommand {
48
56
  rollupOptions: {
49
57
  input: views[view],
50
58
  output: {
51
- format: 'umd',
59
+ format: 'esm',
52
60
  entryFileNames: `${view}.bundle.js`,
61
+ assetFileNames: (assetInfo) => {
62
+ return '[name].[ext]'; // Example: Customize the output file name format
63
+ },
53
64
  }
54
- }
65
+ },
55
66
  }
56
67
  });
57
68
  });
58
- await Promise.allSettled(buildViews).catch(err => {
59
- console.error('Error building:', err);
60
- });
69
+ await Promise.allSettled(buildViews);
61
70
  console.log("Packaging app...");
62
71
  // // write manifest file
63
72
  const manifestPath = `${distPath}/manifest.json`;
@@ -73,13 +82,7 @@ class ForgeCommand {
73
82
  c({ gzip: true, cwd: distPath }, ['.']).pipe(bufferStream).on('finish', () => {
74
83
  client.forge().bundleUpload(buffer).then(() => {
75
84
  console.log('Bundle uploaded successfully');
76
- })
77
- .catch((error) => {
78
- console.error('Bundle error:', error);
79
85
  });
80
- })
81
- .on('error', (error) => {
82
- console.error('Error creating the archive:', error.message);
83
86
  });
84
87
  }
85
88
  else {
@@ -88,17 +91,39 @@ class ForgeCommand {
88
91
  console.log('Bundle created successfully');
89
92
  }
90
93
  catch (error) {
91
- console.error('Error creating the archive:', error.message);
94
+ throw error;
92
95
  }
93
96
  }
94
97
  }
95
98
  async runDev(options) {
96
99
  const { path } = options;
100
+ const host = Util.getCurrentProfile().host;
97
101
  const server = await createServer({
98
102
  root: path, // Set your project root
103
+ define: {
104
+ __ENV_VARIABLES__: JSON.stringify({
105
+ API_HOST: host,
106
+ INTEGRATION_API: `${host}/luma/integrations`,
107
+ PROJECT_API_TOKEN: Util.getCurrentProfile().token,
108
+ })
109
+ }
99
110
  });
100
111
  await server.listen();
112
+ console.log('Current profile:', Util.getCurrentProfile().name);
101
113
  console.log('Dev server running at:', server?.resolvedUrls?.local[0]);
102
114
  }
115
+ async removeVersion(options) {
116
+ const { ref, version } = options;
117
+ const client = Util.getClientForProfile();
118
+ const forge = client.forge();
119
+ await forge.removeVersion(ref, version);
120
+ console.log(`Version ${version} of app ${ref} removed successfully.`);
121
+ }
122
+ async listApps() {
123
+ const client = Util.getClientForProfile();
124
+ const forge = client.forge();
125
+ const { data } = await forge.list();
126
+ console.log(data);
127
+ }
103
128
  }
104
129
  export default new ForgeCommand();
@@ -1,6 +1,6 @@
1
1
  import { Command } from "commander";
2
2
  import util from "../lib/util.js";
3
- import Api from "protokol-sdk";
3
+ import Api from "@ptkl/sdk";
4
4
  import OutputFormatCommand from "./outputCommand.js";
5
5
  class FunctionsCommand {
6
6
  register() {
@@ -15,12 +15,12 @@ class FunctionsCommand {
15
15
  }
16
16
  async list() {
17
17
  const profile = util.getCurrentProfile();
18
- const client = new Api({ project: profile.project, token: profile.token, host: profile.host }).function();
18
+ const client = new Api({ token: profile.token, host: profile.host }).function();
19
19
  return await client.list();
20
20
  }
21
21
  async get(reference) {
22
22
  const profile = util.getCurrentProfile();
23
- const client = new Api({ project: profile.project, token: profile.token, host: profile.host }).function();
23
+ const client = new Api({ token: profile.token, host: profile.host }).function();
24
24
  return await client.get(reference);
25
25
  }
26
26
  }
@@ -5,17 +5,17 @@ import Util from "../lib/util.js";
5
5
  import users from "./apiUsers.js";
6
6
  import functions from "./functions.js";
7
7
  import apps from "./apps.js";
8
- import pull from "./pull.js";
9
8
  import role from "./role.js";
10
9
  import forge from "./forge.js";
10
+ import component from "./component.js";
11
11
  export const commands = [
12
12
  profile.register(),
13
13
  users.register(),
14
14
  functions.register(),
15
15
  apps.register(),
16
- pull.register(),
17
16
  role.register(),
18
17
  forge.register(),
18
+ component.register(),
19
19
  new Command('init')
20
20
  .description("Init protokol toolkit")
21
21
  .action(Util.init)
@@ -1,7 +1,7 @@
1
1
  import { Command } from "commander";
2
2
  import util from "../lib/util.js";
3
3
  import cli from "../lib/cli.js";
4
- import Api from "protokol-sdk";
4
+ import { APIUser } from "@ptkl/sdk";
5
5
  class ProfileCommand {
6
6
  register() {
7
7
  return new Command('profile')
@@ -18,10 +18,8 @@ class ProfileCommand {
18
18
  .action(this.new))
19
19
  .addCommand(new Command('auth')
20
20
  .description('Profile auth')
21
- .option("-n, --name <name>")
22
- .option("-u, --username <username>")
23
21
  .option("-p, --password <password>")
24
- .option("-P, --project <project>")
22
+ .option("-t, --token <token>")
25
23
  .action(this.auth))
26
24
  .addCommand(new Command('list')
27
25
  .description('List all available profiles')
@@ -52,13 +50,14 @@ class ProfileCommand {
52
50
  if (profile) {
53
51
  throw new Error(`Profile with ${name} already exist`);
54
52
  }
55
- const user = new Api({ host, project }).apiUser();
53
+ const user = new APIUser({
54
+ host,
55
+ });
56
56
  // authenticate to protokol
57
- const { data } = await user.apiAuth(username, password);
57
+ const { data } = await user.auth(username, password, project);
58
58
  profiles.push({
59
59
  name,
60
60
  username,
61
- project,
62
61
  token: data.Token,
63
62
  host
64
63
  });
@@ -66,18 +65,20 @@ class ProfileCommand {
66
65
  }
67
66
  async auth(options) {
68
67
  // try to find profile with the name
69
- const { name, username, password, project, host } = options;
70
- const profiles = util.getProfiles() ?? [];
71
- // try to find that the profile with the name already exist
72
- const profile = profiles.find((p) => p.name == name);
73
- if (!profile) {
74
- throw new Error(`Profile with ${name} doesn't exist`);
68
+ const { password, token } = options;
69
+ const profile = util.getCurrentProfile();
70
+ if (!token) {
71
+ const user = new APIUser({
72
+ host: profile.host,
73
+ });
74
+ // authenticate to protokol
75
+ const { data } = await user.auth(profile.username, password, profile.project);
76
+ profile.token = data.Token;
75
77
  }
76
- const user = new Api({ host, project }).apiUser();
77
- // authenticate to protokol
78
- const { data } = await user.apiAuth(username, password);
79
- profile.token = data.Token;
80
- util.updateProfiles(profiles);
78
+ else {
79
+ profile.token = token;
80
+ }
81
+ util.updateProfile(profile);
81
82
  }
82
83
  list() {
83
84
  const profiles = util.getProfiles() ?? [];
@@ -1,6 +1,6 @@
1
1
  import { Command } from "commander";
2
2
  import util from "../lib/util.js";
3
- import Api from "protokol-sdk";
3
+ import Api from "@ptkl/sdk";
4
4
  import OutputFormatCommand from "./outputCommand.js";
5
5
  class RoleCommand {
6
6
  register() {
@@ -34,29 +34,29 @@ class RoleCommand {
34
34
  let { name, permissions, workspaces, level } = options;
35
35
  level = level ? Number(level) : 0;
36
36
  const profile = util.getCurrentProfile();
37
- const client = new Api({ project: profile.project, token: profile.token, host: profile.host }).role();
37
+ const client = new Api({ token: profile.token, host: profile.host }).role();
38
38
  return await client.create({ name, workspaces, permissions, level });
39
39
  }
40
40
  async delete(opts) {
41
41
  const { uuid } = opts;
42
42
  const profile = util.getCurrentProfile();
43
- const client = new Api({ project: profile.project, token: profile.token, host: profile.host }).role();
43
+ const client = new Api({ token: profile.token, host: profile.host }).role();
44
44
  return await client.delete(uuid);
45
45
  }
46
46
  async list() {
47
47
  const profile = util.getCurrentProfile();
48
- const client = new Api({ project: profile.project, token: profile.token, host: profile.host }).role();
48
+ const client = new Api({ token: profile.token, host: profile.host }).role();
49
49
  return await client.list();
50
50
  }
51
51
  async listPermissions() {
52
52
  const profile = util.getCurrentProfile();
53
- const client = new Api({ project: profile.project, token: profile.token, host: profile.host }).role();
53
+ const client = new Api({ token: profile.token, host: profile.host }).role();
54
54
  return await client.list();
55
55
  }
56
56
  async edit(opts) {
57
57
  let { uuid, permissions, workspaces, level } = opts;
58
58
  const profile = util.getCurrentProfile();
59
- const client = new Api({ project: profile.project, token: profile.token, host: profile.host }).role();
59
+ const client = new Api({ token: profile.token, host: profile.host }).role();
60
60
  return await client.edit(permissions, workspaces, Number(level), uuid);
61
61
  }
62
62
  }
@@ -1,46 +1,34 @@
1
1
  import { Command } from "commander";
2
2
  import util from "../lib/util.js";
3
- import Api from "protokol-sdk";
3
+ import Api from "@ptkl/sdk";
4
4
  class ApiUsersCommand {
5
5
  register() {
6
6
  return new Command("users")
7
7
  .description("Manage users")
8
8
  .version("0.1.0")
9
9
  .addCommand(new Command("invite")
10
- .description("invite a new user")
10
+ .description("Invite a new user")
11
11
  .requiredOption("-e, --email <email>", "user email ")
12
- .requiredOption("-r, --roles <roles...>", "uuids of role seprated by space")
12
+ .requiredOption("-r, --roles <roles...>", "uuids of role separated by space")
13
13
  .action(this.invite))
14
14
  .addCommand(new Command("delete")
15
- .description("delete an existing user")
15
+ .description("Remove user from project")
16
16
  .requiredOption("-u, --uuid <uuid>", "UUID of the existing user")
17
- .action(this.delete))
18
- .addCommand(new Command("get-auth-token")
19
- .description("Retrieve an auth token for an API user")
20
- .requiredOption("-u, --user <user>", "Username or name of the API user")
21
- .requiredOption("-p, --password <password>", "Password or secret for the API user")
22
- .action(this.getAuthToken));
17
+ .action(this.delete));
23
18
  }
24
19
  async invite(opts) {
25
20
  const { email, roles } = opts;
26
21
  const profile = util.getCurrentProfile();
27
- const client = new Api({ project: profile.project, token: profile.token, host: profile.host }).user();
22
+ const client = new Api({ token: profile.token, host: profile.host }).user();
28
23
  const secret = await client.invite(email, roles);
29
24
  console.table([secret]);
30
25
  }
31
26
  async delete(opts) {
32
27
  const { uuid } = opts;
33
28
  const profile = util.getCurrentProfile();
34
- const client = new Api({ project: profile.project, token: profile.token, host: profile.host }).user();
29
+ const client = new Api({ token: profile.token, host: profile.host }).user();
35
30
  const status = await client.delete(uuid);
36
31
  console.table([status]);
37
32
  }
38
- async getAuthToken(opts) {
39
- const { user, password } = opts;
40
- const profile = util.getCurrentProfile();
41
- const client = new Api({ project: profile.project, token: profile.token, host: profile.host }).apiUser();
42
- const auth = await client.apiAuth(user, password);
43
- console.log(auth.data.Token);
44
- }
45
33
  }
46
34
  export default new ApiUsersCommand();
package/dist/lib/util.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
2
- import Api from 'protokol-sdk';
2
+ import Api from '@ptkl/sdk';
3
3
  export default class Util {
4
4
  static profilePath = `${process.env.HOME}/.ptkl`;
5
5
  static fileName = "profiles.json";
@@ -22,6 +22,21 @@ export default class Util {
22
22
  throw new Error("There was a problem with updating profiles. Did you run 'init'?");
23
23
  }
24
24
  }
25
+ static updateProfile(profile) {
26
+ try {
27
+ const profiles = Util.getProfiles() ?? [];
28
+ const index = profiles?.findIndex(p => p.name == profile.name);
29
+ if (index === undefined || index < 0) {
30
+ throw new Error("There was a problem with updating profile. Did you run 'init'?");
31
+ }
32
+ profiles[index] = profile;
33
+ Util.updateProfiles(profiles);
34
+ return profile;
35
+ }
36
+ catch (err) {
37
+ throw new Error("There was a problem with updating profile. Did you run 'init'?");
38
+ }
39
+ }
25
40
  static init() {
26
41
  try {
27
42
  mkdirSync(Util.profilePath, { recursive: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptkl/toolkit",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "scripts": {
5
5
  "test": "echo \"Error: no test specified\" && exit 1",
6
6
  "build": "npx tsc",
@@ -10,18 +10,27 @@
10
10
  "author": "",
11
11
  "license": "MIT",
12
12
  "description": "",
13
+ "type": "module",
13
14
  "dependencies": {
15
+ "@babel/standalone": "^7.26.10",
16
+ "@ptkl/sdk": "^0.4.0",
14
17
  "@types/axios": "^0.14.0",
15
18
  "@types/commander": "^2.12.2",
16
19
  "@types/js-yaml": "^4.0.9",
20
+ "@vue/compiler-sfc": "^3.5.13",
17
21
  "axios": "^1.7.4",
18
22
  "chalk": "^4.1.2",
19
23
  "chokidar": "^4.0.1",
20
24
  "circular-json": "^0.5.9",
21
25
  "commander": "^12.1.0",
22
26
  "js-yaml": "^4.1.0",
23
- "protokol-sdk": "file:../protokol-sdk",
27
+ "less": "^4.1.1",
28
+ "lodash": "^4.17.21",
29
+ "open": "^10.1.2",
30
+ "rollup": "^4.34.6",
24
31
  "tar": "^7.4.3",
32
+ "vite": "^6.0.6",
33
+ "vue-template-compiler": "^2.7.16",
25
34
  "ws": "^8.18.0",
26
35
  "yaml": "^2.5.0"
27
36
  },
@@ -34,6 +43,6 @@
34
43
  "dist"
35
44
  ],
36
45
  "bin": {
37
- "pkit": "dist/bin/toolkit"
46
+ "ptkl": "dist/bin/toolkit.js"
38
47
  }
39
48
  }