@getxflow/cli 0.30.0 → 0.31.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.
@@ -49,27 +49,38 @@ async function templates() {
49
49
  }
50
50
  (0, ui_1.table)(list.map((t) => [t.id, t.name, t.is_default ? 'default' : '', t.description ?? '']));
51
51
  }
52
- /**
53
- * A function name out of the project name: the platform takes lowercase latin
54
- * letters, digits and dashes, and the folder it lives in gives it its name.
55
- */
56
- function functionNameFrom(name) {
57
- const slug = name
52
+ function slugify(name) {
53
+ return name
58
54
  .toLowerCase()
59
55
  .replace(/[^a-z0-9-]+/g, '-')
60
56
  .replace(/^-+|-+$/g, '')
61
57
  .slice(0, 41);
62
- if (!/^[a-z0-9][a-z0-9-]{0,40}$/.test(slug)) {
63
- throw new errors_1.CliError(`Cannot make a function name out of "${name}"`, 'Name it in latin letters, digits and dashes: xflow init my-fn --function');
64
- }
65
- return slug;
58
+ }
59
+ /**
60
+ * A function name out of the project name: the platform takes lowercase latin
61
+ * letters, digits and dashes, and the folder it lives in gives it its name.
62
+ *
63
+ * The folder name is the fallback, so a project called in Russian still gets a
64
+ * function: the name a person reads and the name the cloud takes are different
65
+ * things, and the folder already holds a usable one.
66
+ */
67
+ function functionNameFrom(name, folder) {
68
+ const usable = /^[a-z0-9][a-z0-9-]{0,40}$/;
69
+ const slug = slugify(name);
70
+ if (usable.test(slug))
71
+ return slug;
72
+ const fromFolder = folder ? slugify(folder) : '';
73
+ if (usable.test(fromFolder))
74
+ return fromFolder;
75
+ throw new errors_1.CliError(`Cannot make a function name out of "${name}"`, 'The name comes from the project name, and the folder is the fallback: name either of them in latin ' +
76
+ 'letters, digits and dashes (xflow init my-fn --function)');
66
77
  }
67
78
  /**
68
79
  * Create a standalone function: a shared backend of the organization, a project
69
80
  * without a site. No template is fetched — there is no frontend to fetch.
70
81
  */
71
82
  async function initFunction(args, client, target, name) {
72
- const functionName = functionNameFrom(name);
83
+ const functionName = functionNameFrom(name, (0, node_path_1.basename)(target));
73
84
  (0, ui_1.step)('Creating the function on the platform');
74
85
  const project = await (0, api_1.apiJson)(client, '/api/v1/projects', {
75
86
  method: 'POST',
package/dist/version.js CHANGED
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DEFAULT_API_URL = exports.CLI_VERSION = void 0;
4
4
  /** Keep in sync with cli/package.json. */
5
- exports.CLI_VERSION = '0.30.0';
5
+ exports.CLI_VERSION = '0.31.0';
6
6
  /** Overridden by XFLOW_API_URL or the `api` field in xflow.json. */
7
7
  exports.DEFAULT_API_URL = 'https://app.getxflow.com';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getxflow/cli",
3
- "version": "0.30.0",
3
+ "version": "0.31.0",
4
4
  "description": "CLI for the XFlow platform: source sync, deployment and publishing of applications",
5
5
  "license": "UNLICENSED",
6
6
  "engines": {
@@ -22,7 +22,7 @@ contains the fix.
22
22
 
23
23
  ## Keeping these instructions current
24
24
 
25
- These instructions ship with xflow CLI 0.30.0, so the copy you are reading can be older than
25
+ These instructions ship with xflow CLI 0.31.0, so the copy you are reading can be older than
26
26
  the CLI answering your commands.
27
27
 
28
28
  When the CLI says this file does not match it, run `xflow skills --refresh` and then **read
@@ -223,7 +223,8 @@ application, in that order. `xflow functions list` shows what is live. The handl
223
223
  `{ statusCode, body }` where `body` is a JSON string.
224
224
 
225
225
  A function that belongs to no single application is created on its own: `xflow init <dir>
226
- --function` makes a project without a site, with one handler and no template. It is a shared
226
+ --function` makes a project without a site, with one handler and no template. The function name
227
+ comes from the project name, or from the folder when the project name is not latin. It is a shared
227
228
  backend of the organization, and any application of that organization calls it; who is let in
228
229
  is decided by `minRole` inside the function. Deploy builds and releases it the same way, but it
229
230
  has no pages, so `xflow publish` and `xflow rollback` do not apply; an earlier version comes back