@ptkl/toolkit 0.10.3 → 0.11.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.
@@ -69,6 +69,7 @@ class ForgeCommand {
69
69
  .description("Bundle app")
70
70
  .requiredOption("-p, --path <path>", "Path is directory where app is located.")
71
71
  .option("-u, --upload", "Upload bundle")
72
+ .option("-m, --mode <mode>", "Vite build mode (controls which .env.[mode] files are loaded). Defaults to 'production'.")
72
73
  .action(this.bundle))
73
74
  .addCommand(new Command("remove-version")
74
75
  .description("Remove version of app")
@@ -79,6 +80,7 @@ class ForgeCommand {
79
80
  .description("Run dev app")
80
81
  .requiredOption("-p, --path <path>", "Path is directory where app is located.")
81
82
  .option("--platform-url <url>", "Platform UI URL (e.g. http://localhost:8081) — required for window.requestForgePermissions in dev mode")
83
+ .option("-m, --mode <mode>", "Vite mode (controls which .env.[mode] files are loaded). Defaults to 'development'.")
82
84
  .action(this.runDev))
83
85
  .addCommand(new Command("list")
84
86
  .description("List all available apps")
@@ -97,7 +99,7 @@ class ForgeCommand {
97
99
  .action((options) => this.uninstall(options)));
98
100
  }
99
101
  async bundle(options) {
100
- const { path, upload } = options;
102
+ const { path, upload, mode } = options;
101
103
  // Store original working directory
102
104
  const originalCwd = process.cwd();
103
105
  try {
@@ -139,6 +141,7 @@ class ForgeCommand {
139
141
  try {
140
142
  await build({
141
143
  root: path,
144
+ mode: mode ?? 'production',
142
145
  build: {
143
146
  outDir: distPath,
144
147
  emptyOutDir: true,
@@ -157,6 +160,7 @@ class ForgeCommand {
157
160
  console.log('Building SSR renderer...');
158
161
  await build({
159
162
  root: path,
163
+ mode: mode ?? 'production',
160
164
  build: {
161
165
  outDir: distPath,
162
166
  emptyOutDir: false,
@@ -197,6 +201,7 @@ class ForgeCommand {
197
201
  try {
198
202
  const result = await build({
199
203
  root: path,
204
+ mode: mode ?? 'production',
200
205
  base: bundleBasePath,
201
206
  build: {
202
207
  outDir: distPath,
@@ -225,9 +230,9 @@ class ForgeCommand {
225
230
  const runtimeBaseResolver = `const __ptklForgeBundleBase=()=>{const env=typeof window!=='undefined'&&window.__ENV_VARIABLES__?window.__ENV_VARIABLES__.API_HOST:'';const host=typeof env==='string'?env.replace(/\\/$/,''):'';return host+'${bundleBasePath}';};\n`;
226
231
  chunk.code = runtimeBaseResolver + chunk.code;
227
232
  // Transform dynamic imports in the final bundled code
228
- chunk.code = chunk.code.replace(/import\(['"`]\.\/([^'"`]+)['"`]\)/g, `dynamicImport(__ptklForgeBundleBase() + '$1')`);
233
+ chunk.code = chunk.code.replace(/import\(['`"]\.\/([^'`"]+)['`"]\)/g, `dynamicImport(__ptklForgeBundleBase() + '$1')`);
229
234
  // Also handle relative paths without ./
230
- chunk.code = chunk.code.replace(/import\(['"`]([^'"`\/]+\.js)['"`]\)/g, `dynamicImport(__ptklForgeBundleBase() + '$1')`);
235
+ chunk.code = chunk.code.replace(/import\(['`"]([^'`"\/]+\.js)['`"]\)/g, `dynamicImport(__ptklForgeBundleBase() + '$1')`);
231
236
  }
232
237
  }
233
238
  }
@@ -245,6 +250,7 @@ class ForgeCommand {
245
250
  try {
246
251
  const result = await build({
247
252
  root: path,
253
+ mode: mode ?? 'production',
248
254
  base: bundleBasePath,
249
255
  build: {
250
256
  outDir: distPath,
@@ -366,7 +372,7 @@ class ForgeCommand {
366
372
  }
367
373
  }
368
374
  async runDev(options) {
369
- const { path, platformUrl } = options;
375
+ const { path, platformUrl, mode } = options;
370
376
  const host = Util.getCurrentProfile().host;
371
377
  // Load ptkl.config.js to discover views and app name
372
378
  let appName;
@@ -393,16 +399,16 @@ class ForgeCommand {
393
399
  // kernel globals that normally come from the platform-forge runtime.
394
400
  const server = await createServer({
395
401
  root: path,
402
+ mode: mode ?? 'development',
396
403
  define: {
397
404
  __ENV_VARIABLES__: JSON.stringify({
398
405
  API_HOST: host,
399
406
  INTEGRATION_API: `${host}/luma/integrations`,
400
407
  PROJECT_API_TOKEN: Util.getCurrentProfile().token,
401
- PLATFORM_URL: platformUrl ? platformUrl : "https://platform.protokol.io"
402
408
  }),
403
409
  DEV_HUB_PORT
404
410
  },
405
- plugins: [forgeDevKernelPlugin(appName, platformUrl ?? 'https://platform.protokol.io')],
411
+ plugins: [forgeDevKernelPlugin(appName, platformUrl)],
406
412
  });
407
413
  await server.listen();
408
414
  console.log('Current profile:', Util.getCurrentProfile().name);
@@ -8,6 +8,7 @@ import apps from "./apps.js";
8
8
  import role from "./role.js";
9
9
  import forge from "./forge.js";
10
10
  import component from "./component.js";
11
+ import workflow from "./workflow.js";
11
12
  import generateTypes from "./generate-types.js";
12
13
  import validateIDL from "./validate-idl.js";
13
14
  export const commands = [
@@ -18,6 +19,7 @@ export const commands = [
18
19
  role.register(),
19
20
  forge.register(),
20
21
  component.register(),
22
+ workflow.register(),
21
23
  generateTypes.register(),
22
24
  validateIDL.register(),
23
25
  new Command('init')
@@ -0,0 +1,40 @@
1
+ import { Command } from "commander";
2
+ import { Platform as Api } from "@ptkl/sdk";
3
+ import util from "../lib/util.js";
4
+ import OutputFormatCommand from "./outputCommand.js";
5
+ class WorkflowCommand {
6
+ register() {
7
+ return new Command("workflow")
8
+ .description("Manage project workflows")
9
+ .version("0.1.0")
10
+ .addCommand(new OutputFormatCommand(new Command("settings")
11
+ .description("Get settings for a workflow")
12
+ .requiredOption("-r, --ref <ref>", "Workflow name or UUID")).action(this.getSettings))
13
+ .addCommand(new OutputFormatCommand(new Command("list")
14
+ .description("List all workflows for the current project")).action(this.list))
15
+ .addCommand(new OutputFormatCommand(new Command("get")
16
+ .description("Get a workflow by name or UUID")
17
+ .requiredOption("-r, --ref <ref>", "Workflow name or UUID")).action(this.get));
18
+ }
19
+ async getSettings(opts) {
20
+ const { ref } = opts;
21
+ const profile = util.getCurrentProfile();
22
+ const client = new Api({ token: profile.token, host: profile.host }).workflow();
23
+ const { data } = await client.get(ref);
24
+ return data.settings;
25
+ }
26
+ async list(opts) {
27
+ const profile = util.getCurrentProfile();
28
+ const client = new Api({ token: profile.token, host: profile.host }).workflow();
29
+ const { data } = await client.list();
30
+ return data;
31
+ }
32
+ async get(opts) {
33
+ const { ref } = opts;
34
+ const profile = util.getCurrentProfile();
35
+ const client = new Api({ token: profile.token, host: profile.host }).workflow();
36
+ const { data } = await client.get(ref);
37
+ return data;
38
+ }
39
+ }
40
+ export default new WorkflowCommand();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptkl/toolkit",
3
- "version": "0.10.3",
3
+ "version": "0.11.0",
4
4
  "description": "A command-line toolkit for managing Protokol platform applications, profiles, functions, and components",
5
5
  "keywords": [
6
6
  "protokol",
@@ -35,7 +35,7 @@
35
35
  "@babel/preset-typescript": "^7.28.5",
36
36
  "@babel/standalone": "^7.26.10",
37
37
  "@inquirer/password": "^4.0.21",
38
- "@ptkl/sdk": "^1.5.1",
38
+ "@ptkl/sdk": "^1.9.2",
39
39
  "@rollup/plugin-babel": "^6.1.0",
40
40
  "@rollup/plugin-commonjs": "^29.0.0",
41
41
  "@rollup/plugin-node-resolve": "^16.0.3",