@flourish/sdk 3.17.2 → 3.19.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.
Files changed (43) hide show
  1. package/README.md +1 -0
  2. package/README.md~ +473 -0
  3. package/RELEASE_NOTES.md +12 -0
  4. package/RELEASE_NOTES.md~ +372 -0
  5. package/bin/{flourish → flourish.js} +31 -42
  6. package/lib/cmd/assign-version-number.js +4 -6
  7. package/lib/cmd/build.js +6 -10
  8. package/lib/cmd/delete.js +4 -6
  9. package/lib/cmd/help.js +3 -5
  10. package/lib/cmd/history.js +4 -6
  11. package/lib/cmd/list.js +4 -6
  12. package/lib/cmd/login.js +5 -7
  13. package/lib/cmd/logout.js +3 -5
  14. package/lib/cmd/new.js +3 -5
  15. package/lib/cmd/publish.js +9 -10
  16. package/lib/cmd/register.js +5 -7
  17. package/lib/cmd/run.js +3 -5
  18. package/lib/cmd/upgrade/1-convert-config-to-yaml.js +6 -8
  19. package/lib/cmd/upgrade/2-convert-index-html.js +3 -4
  20. package/lib/cmd/upgrade/3-add-build-config.js +3 -4
  21. package/lib/cmd/upgrade/4-remove-autoheight-config.js +3 -4
  22. package/lib/cmd/upgrade/index.js +5 -7
  23. package/lib/cmd/version.js +5 -13
  24. package/lib/cmd/whoami.js +4 -6
  25. package/lib/log.js +7 -7
  26. package/lib/sdk.js +43 -54
  27. package/lib/sdk.js~ +540 -0
  28. package/lib/validate_config.js +7 -1
  29. package/lib/validate_config.js~ +437 -0
  30. package/package-lock.json~ +2669 -0
  31. package/package.json +5 -5
  32. package/package.json~ +53 -0
  33. package/server/comms_js.js +1 -0
  34. package/server/data.js +40 -5
  35. package/server/index.js~ +540 -0
  36. package/server/views/index.html +9 -5
  37. package/site/embedded.js +1 -1
  38. package/site/images/flourish_in_canva.png +0 -0
  39. package/site/images/share_image.jpg +0 -0
  40. package/site/script.js +2 -2
  41. package/site/sdk.css +1 -1
  42. package/test/lib/validate_config.js +11 -2
  43. package/test/lib/validate_config.js~ +1006 -0
@@ -0,0 +1,372 @@
1
+ <<<<<<< HEAD
2
+ # 3.13.1
3
+
4
+ * Fix a regression that caused errors in a template with no settings: block defined in its template.yml. #63
5
+ =======
6
+ # 3.14.0
7
+
8
+ * Add a “watch” option for build rules, to use a custom watcher
9
+ >>>>>>> sdk-watch-command
10
+
11
+ # 3.13.0
12
+
13
+ * Support is_optional on font type settings so that they can be set to null
14
+ * Support is_optional on color type settings so that they can be set to null
15
+
16
+ # 3.12.0
17
+
18
+ * Support hide_if and show_if properties for components so that whole blocks of imported settings can be easily hidden.
19
+ * Support extending (as an alternative to replacing) entities through overrides
20
+ * Support 'property' property of override object being an array of properties
21
+ * Support template show_if/hide_if conditionals referencing imported component properties
22
+
23
+ # 3.11.7
24
+
25
+ * Fix bug with boolean-valued show_if/hide_if in settings.yml of modules
26
+
27
+ # 3.11.6
28
+
29
+ * Fix show_if and hide_if conditionals involving data bindings
30
+
31
+ # 3.11.5
32
+
33
+ * Print date and time when publishing a template.
34
+
35
+ # 3.11.4
36
+
37
+ * The “flourish register” command used to fail at the point of asking you to enter a password if you are using Node 10. This version fixes that problem.
38
+
39
+ # 3.11.3
40
+
41
+ * Add support for `svg_download`, which you should now set to `false` for templates where SVG download wouldn't produce useful results (for example if the only SVG in the template is a legend, not the main chart)
42
+
43
+ # 3.11.2
44
+
45
+ * Do not allow template settings to be conditional on themselves.
46
+
47
+ # 3.11.1
48
+
49
+ * Fix bug that broke show_if/hide_if settings rules.
50
+
51
+ # 3.11.0
52
+
53
+ * Update all node modules to their current versions. This also means that templates created with “flourish new” will be configured to use the current version of rollup.
54
+ * New design for settings panel (matching flourish.studio). Checkboxes are now iOS-style toggle switches, and editing the color palette opens the palette editor in a separate overlay.
55
+
56
+ # 3.10.3
57
+
58
+ * Update the documentation for the `colors` setting type.
59
+
60
+ # 3.10.2
61
+
62
+ * One of the dependency packages used by the SDK fails to compile with versions of node earlier than 8.3. Update the "engines" specification in package.json to specify that we require node 8.3 or later.
63
+
64
+ # 3.10.1
65
+
66
+ * Template name and author were being inserted into the page unescaped, which would cause problems if either contains characters such as `<` that have a special meaning in HTML. This is now fixed.
67
+
68
+ # 3.10.0
69
+
70
+ * Log a warning to the console if the draw() or update() functions are declared to have parameters. #19
71
+ * Support the `--as` flag consistently across commands. (This change only affects internal users at Flourish HQ.)
72
+
73
+ # 3.9.2
74
+
75
+ * The “flourish login” command was failing at the password prompt, with Node 10. Change the way we read the password, so it works. #56
76
+
77
+ # 3.9.1
78
+
79
+ * Allow "type: hidden" properties under settings in template.yml, for documenting state that isn't an exposed setting. This is intend to help document the template for programmatic use via the upcoming API.
80
+ * Document the suggestion that such state documentation is under a "State documentation" settings block.
81
+
82
+ # 3.9.0
83
+
84
+ * Add the “flourish history” command to the output of “flourish help”.
85
+ * Add the optional template id parameter for “flourish list” to the output of “flourish help”.
86
+ * Raise an error if “flourish history” is called with no argument.
87
+ * Set the NODE_ENV environment variable to "production" or "development" depending on whether the build was triggered by `flourish publish` or `flourish run`.
88
+ * New command `flourish assign-version-number`, which must be used to assign a version number to an already-published template before it can be republished.
89
+
90
+ # 3.8.0
91
+
92
+ * Add a new undocumented “flourish publish” option `--local-testing`, which is only useful if you are running your own instance of the Flourish server.
93
+
94
+ # 3.7.1
95
+
96
+ * Skeleton project: suppress “circular dependency” warnings in the rollup configuration.
97
+
98
+ # 3.7.0
99
+
100
+ * Introduces new "font" setting type.
101
+ * Allow headings in imported setting blocks
102
+ * Take metadata from package.json, if present. #35
103
+ Specifically:
104
+ * Use the author, description and version fields from package.json if the
105
+ corresponding field is missing from template.yml.
106
+ * Use the name from package.json as the template id, if the template.yml has no id.
107
+ * Respect the version number (as per semver.org): if the major version number is not incremented, assume the new version is backwards-compatible and upgrade existing visualisations. If the major version number is incremented, leave existing visualisations connected to the previous version.
108
+ * Add --patch, --prerelease and --release options to “flourish publish”.
109
+ * Make it possible to pass a template id as a parameter to “flourish list”, to list the available versions of a particular template.
110
+ * Add a version parameter to “flourish delete”.
111
+ * Add a “flourish history” command, to show the versions of a template that are available for use in the Live API.
112
+
113
+ # 3.6.0
114
+
115
+ * Fix a bug that meant conditional settings could not refer to a setting whose name begins with "data". #45
116
+ * `flourish list` now recognises the `--full` option.
117
+ * `flourish delete` now has a `--force` option that makes it possible to delete a template even if there are associated visualisations, provided they were created by the same user who created the template.
118
+
119
+ # 3.5.0
120
+
121
+ * `flourish new` now generates skeleton code for SDK version 3
122
+ * What was called `api_token` is now called `sdk_token`. This is a purely internal change, which should not affect developers using the SDK to develop Flourish templates. (Developers running their own instances of the Flourish app will need to ensure they have an up-to-date version of Flourish. On the other hand, older versions of the SDK are compatible with the newer Flourish app.)
123
+
124
+ # 3.4.0
125
+
126
+ * Modules imported using the “import” syntax are now resolved using
127
+ Node's [`require.resolve` algorithm](https://nodejs.org/api/modules.html#modules_all_together).
128
+ * New “override” property for imported settings.
129
+
130
+ # 3.3.1
131
+
132
+ * New `joinable_data` property can be specified in template.yml.
133
+ This is currently an undocumented feature intended for internal
134
+ use by Flourish.
135
+ * Since 3.3.0, the SDK now only supports Node 8+. This is now specified in `package.json`.
136
+
137
+ # 3.3.0
138
+
139
+ * Added new `colors` setting type for palette picking.
140
+ * New “import” syntax to import groups of settings from a node module.
141
+
142
+ # 3.2.0
143
+
144
+ * After upgrading template.yml, write it back out with { flowLevel: 4 }, which makes the YAML come out more like the way we write it in the documentation. In practice this only affects choices for settings in key-value format, since that is the only place currently where the structure is nested four levels deep.
145
+
146
+ # 3.1.0
147
+
148
+ * Minor fix to the error handling in the template upgrade code.
149
+ * Having an `autoheight` property in template.yml is now an error rather than a warning.
150
+ * Updated tests.
151
+
152
+ # 3.0.0
153
+
154
+ This is a major version change, and a forced upgrade: older versions of the SDK can no longer publish templates to Flourish. The `autoheight` property is no longer supported, and instead iframe height is automatically set using default breakpoints. For templates that need to adjust the iframe height dynamically, there is a new method `Flourish.setHeight()`.
155
+
156
+ Templates now need to have `sdk_version: 3` in their template.yml. Old templates can be upgraded by running `flourish upgrade`.
157
+
158
+ # 2.16.1
159
+
160
+ * Upgrade node modules (mocha → 5.1.1, rollup → 0.58.0)
161
+ * Improve error message from “flourish login” in the case where the server returns something unexpected. (This is mainly useful for testing changes to Flourish itself: this should never happen in normal operation.)
162
+
163
+ # 2.16.0
164
+
165
+ * Tweak the Flourish logo, and make it link to the live app.
166
+ * Change the “prepublish” npm script to “prepare”, to be compatible with future versions of NPM.
167
+ * Set the file permissions of the .flourish_sdk file so that only the current user can read it.
168
+
169
+ # 2.15.2
170
+
171
+ * Slightly better fix for #40, so that the temporary zip file is still deleted on exit.
172
+
173
+ # 2.15.1
174
+
175
+ * Upgrade ws module to 5.1.1.
176
+ * Avoid crash after publishing a template. #40
177
+
178
+ # 2.15.0
179
+
180
+ * Upgrade all node module dependencies to their current versions. This will also
181
+ affect new user projects created with the “flourish new” command.
182
+ * Support the --no-build option for “flourish publish”.
183
+ * New setting type “code”.
184
+ * New “size: large” option for text and code settings.
185
+
186
+ # 2.14.0
187
+
188
+ * Drop support for specifying a username in the `id` of `template.yml` by setting id to `<username>/<template>`. Specifying one now throws an error when publishing a template. (This feature was only used internally for Flourish templates on the @flourish account. This should not affect external users of the SDK.)
189
+
190
+ # 2.13.0
191
+
192
+ Major change: the preview pane is now embedded using the same height-adjustment
193
+ logic as when a published visualisation is embedded on another site. If the
194
+ preview pane is set to a fixed height, then `Flourish.fixed_height` is true
195
+ in the template.
196
+
197
+ Bug fixes:
198
+ * Fixes boolean button group bugs
199
+ * With a subhead in place, the new_section line didn't get hidden properly
200
+ * Only send nulls for empty number settings
201
+
202
+ # 2.12.1
203
+
204
+ * Handle strings containing U+2028 or U+2029 characters in data.
205
+
206
+ # 2.12.0
207
+
208
+ * New `is_master_slide` property can be specified in template.yml.
209
+ This is currently an undocumented feature intended for internal
210
+ use by Flourish.
211
+ * New setting width option “three quarters”.
212
+ * Settings display can now be conditional on data bindings being set.
213
+ * Boolean settings can specify `choices` in template.yml to display as buttons.
214
+ * Add tests for template.yml validation, fix some validation bugs, and make some
215
+ error messages more consistent.
216
+
217
+ # 2.11.0
218
+
219
+ * New `credits:` property can be specified in template.yml
220
+
221
+ # 2.10.1
222
+
223
+ * Give a sensible error message if conditional settings configuration
224
+ (`show_if:`) blocks are indented incorrectly.
225
+ * Correct the formatting of the `show_if` examples in README.md
226
+ * Hide section dividers when setting is hidden
227
+
228
+ # 2.10.0
229
+
230
+ * The template documentation is now taken from `GUIDE.md` if there is
231
+ such a file, and only from `README.md` as a fallback if `GUIDE.md`
232
+ does not exist.
233
+ * Settings can now be displayed conditionally on the values of other settings.
234
+ See the “Conditional settings” section of the documentation.
235
+
236
+ # 2.9.1
237
+
238
+ * Fix botched release (with many missing files) that was caused by
239
+ a bug in npm: See https://github.com/npm/npm/issues/18461
240
+
241
+ # 2.9.0
242
+
243
+ * New settings layout options:
244
+ * width: half
245
+ * width: quarter
246
+ * new_section: true
247
+ * style: buttons
248
+
249
+ See https://flourish.rocks/developers/reference/template-files.html#settings
250
+
251
+ * Add support for optional column bindings.
252
+ * Add --listen option for `flourish run` to listen on a non-localhost interface.
253
+ * Add support for `image_download: false`
254
+ * Upgrade d3-dsv to 1.0.7. #17
255
+ * Match data table names case-sensitively, even on case-insensitive filesystems. #25
256
+ * Warn if there is no autoheight configuration.
257
+ * Upgrade skeleton project to rollup 0.50.0
258
+
259
+ # 2.8.0
260
+
261
+ * Add missing font files. #21
262
+ * Add support for optional number settings. If “optional: true” is specified,
263
+ and no value is supplied for the setting, then a null value will be passed to
264
+ the template rather than zero.
265
+ * Fix “Uncaught TypeError: Cannot read property 'fireEvent' of undefined” #22
266
+
267
+ # 2.7.0
268
+
269
+ * New metadata property in template.yml “autoheight” to specify how the width of
270
+ the embed should depend on the height when an auto-height embed is used.
271
+ * String settings can now have a “choices” property which restricts the values
272
+ users can enter, and displays the setting as a dropdown list rather than a
273
+ free-text field. If the optional “choices_other” property is also true, the
274
+ user may type free text in addition to selecting from the listed choices.
275
+ The choices property should be an array of strings or pairs of strings: if
276
+ a pair of strings is given, the first element is displayed to the user on the
277
+ dropdown menu and the second is used as the value of the setting.
278
+ * New data binding description metadata property in template.yml: in the data
279
+ section, if a second string is supplied immediately following the binding
280
+ name, it will be treated as the binding decription, and displayed to the
281
+ user in the data bindings panel.
282
+ * Run “npm install” rather than “npm update” to install modules. (Newer versions
283
+ of NPM will update package.json and package-lock.json when “npm update” is used.)
284
+
285
+ # 2.6.0
286
+
287
+ * Bundle fonts locally, so the SDK doesn’t need an internet connection.
288
+ * Work around a browser-dependent issue where mousewheel scrolling sometimes
289
+ did not work after the viewport had been resized. #14
290
+ * Fix file watching when the template directory is not the current directory. #15
291
+
292
+ # 2.5.5
293
+
294
+ * More efficient generation of HTML: significantly faster reloads for
295
+ large data tables. #11
296
+ * Avoid reloading many times in parallel when switching branches in git. #12
297
+
298
+ # 2.5.4
299
+
300
+ * Don’t show the “pointer” icon on the rotate button when it’s disabled.
301
+
302
+ # 2.5.3
303
+
304
+ * Specify in package.json that it only works with Node 6 and later.
305
+
306
+ # 2.5.2
307
+
308
+ * Remove another popup that slipped through the net in 2.5.1.
309
+
310
+ # 2.5.1
311
+
312
+ * Fix resizing on IE11 and Edge.
313
+ * Remove popups that don’t display properly.
314
+
315
+ # 2.5.0
316
+
317
+ * New preview interface, matching the new visualisation editor
318
+ on flourish.studio
319
+
320
+ # 2.4.1
321
+
322
+ * Fix bug affecting error reporting for invalid data bindings
323
+ * Ignore repeated and trailing slashes in build rule directory paths
324
+ * Handle CSV files that have a UTF-8 BOM, as saved by Excel
325
+
326
+ # 2.4.0
327
+
328
+ * Add “flourish --version”, to print the SDK version number.
329
+
330
+ # 2.3.1
331
+
332
+ * Update top-level “flourish help”.
333
+ * Refer to the help command if you just type “flourish”.
334
+ * Do not include meta tags in SDK HTML.
335
+ * Remove full path to lessc script in the skeleton package.json, because it
336
+ was not working on Windows.
337
+
338
+ # 2.3.0
339
+
340
+ * Add command-line help with “flourish help”.
341
+ * “flourish delete” now takes a template id, not a template directory.
342
+
343
+ # 2.2.0
344
+
345
+ * Cross-platform compatibility improvements: it should now work correctly on
346
+ Windows, Mac and Linux.
347
+ * Run “`npm update`” on build if `package.json` exists but `node_modules` does not
348
+ * Better error reporting if “`flourish upgrade`” is run and neither `template.yml`
349
+ nor `settings.js` exist.
350
+ * “flourish whoami” prints your username, rather than your email address
351
+ * Remove top menu; "Preview" mode now available as "Standalone" via the view menu
352
+ * Legal nonsense:
353
+ * Add license
354
+ * Agree to Terms and Conditions when you register
355
+ * An unfortunate consequence of the previous point is that older versions of
356
+ the SDK are no longer allowed to communicate with the server, and users are
357
+ prompted to upgrade
358
+ * Use Handlebars rather than Mustache internally
359
+ * Dogfood note: our internal templates may specify `flourish/identifier` in their
360
+ `id` field, so when we publish them they’re linked to the `flourish` user.
361
+ This only works if you’re logged in as an admin user.
362
+
363
+ # 2.1.0
364
+
365
+ * Add an option (`--as`) that only works for admin users.
366
+ * Serve source maps (`template.js.map`) for easier debugging of templates.
367
+ * Correct documentation for data bindings. Issue a better error message
368
+ for data bindings that don’t have suitable `column` or `columns` specifications.
369
+ Thanks to Tim Brock.
370
+ * Add release notes!
371
+ * Fix the “Editor” link in the SDK header.
372
+ * Mention “flourish register” in the quickstart notes.
@@ -55,59 +55,48 @@ process.on("unhandledRejection", function(reason, p) {
55
55
  throw reason;
56
56
  });
57
57
 
58
+ const COMMANDS = [
59
+ "help",
60
+ "version",
61
+ "new",
62
+ "build",
63
+ "run",
64
+ "register",
65
+ "login",
66
+ "logout",
67
+ "whoami",
68
+ "assign-version-number",
69
+ "publish",
70
+ "delete",
71
+ "upgrade",
72
+ "list",
73
+ "history"
74
+ ];
75
+
58
76
  function main() {
59
77
  const args = minimist(process.argv.slice(2), OPTS);
60
78
 
79
+ if (args._[0] === "is" && args._[1] === "the") {
80
+ return log.victory("Word!");
81
+ }
82
+
61
83
  // minimist unhelpfully treats numeric strings as numbers;
62
84
  // which means we have to turn them back into strings.
63
- args._ = args._.map(x => "" + x);
64
-
65
- let command = args._[0];
66
-
67
- const server_opts = {
68
- host: args.host,
69
- user: args.user,
70
- password: args.password,
71
- };
85
+ args._ = args._.map(String);
72
86
 
87
+ let [command] = args._;
73
88
  if (args.version) command = "version";
74
89
  else if (args.help) command = "help";
75
90
 
76
- switch (command) {
77
- case "help":
78
- case "version":
79
-
80
- case "new":
81
- case "build":
82
- case "run":
83
-
84
- case "register":
85
- case "login":
86
- case "logout":
87
-
88
- case "whoami":
89
-
90
- case "assign-version-number":
91
- case "publish":
92
- case "delete":
93
- case "upgrade":
94
- case "list":
95
- case "history":
96
- require("../lib/cmd/" + command)(args, server_opts);
97
- break;
98
-
99
- case "is":
100
- if (args._[1] === "the") {
101
- log.victory("Word!");
102
- break;
103
- }
104
-
105
- default:
106
- log.die("Unknown command '" + command + "'. Type 'flourish help' for help.");
91
+ if (!command) {
92
+ return log.die("No command specified. Type ‘flourish help’ for help.");
93
+ }
107
94
 
108
- case undefined:
109
- log.die("No command specified. Type flourish help for help.");
95
+ if (!COMMANDS.includes(command)) {
96
+ return log.die(`Unknown command '${command}'. Type 'flourish help' for help.`);
110
97
  }
98
+
99
+ require("../lib/cmd/" + command).command(args);
111
100
  }
112
101
 
113
102
  main();
@@ -5,7 +5,7 @@ const semver = require("@flourish/semver");
5
5
  const log = require("../log"),
6
6
  sdk = require("../sdk");
7
7
 
8
- function assign_version_number(args, server_opts) {
8
+ exports.command = function assign_version_number(args) {
9
9
  let template_id_promise, template_version;
10
10
  if (args._.length == 2) {
11
11
  // Assume the supplied argument is a version number, and try to get the id from the current directory
@@ -27,7 +27,7 @@ function assign_version_number(args, server_opts) {
27
27
 
28
28
  template_id_promise.then(template_id => {
29
29
  if (args.as) template_id = args.as + "/" + template_id;
30
- return sdk.request(server_opts, "template/assign-version-number", { id: template_id, version: template_version })
30
+ return sdk.request(args, "template/assign-version-number", { id: template_id, version: template_version })
31
31
  .then(() => {
32
32
  log.success(`Assigned version number ${template_version} to template ${template_id}`);
33
33
  });
@@ -36,14 +36,12 @@ function assign_version_number(args, server_opts) {
36
36
  if (args.debug) log.die("Failed to assign version number", error.message, error.stack);
37
37
  else log.die("Failed to assign version number", error.message);
38
38
  });
39
- }
39
+ };
40
40
 
41
- assign_version_number.help = `
41
+ exports.help = `
42
42
  flourish assign-version-number [template-id] version
43
43
 
44
44
  Assign a version number to a template that does not have one yet.
45
45
  If template-id is omitted, uses the id of the template in the
46
46
  current directory.
47
47
  `;
48
-
49
- module.exports = assign_version_number;
package/lib/cmd/build.js CHANGED
@@ -5,7 +5,7 @@ var fs = require("fs"),
5
5
  log = require("../log"),
6
6
  sdk = require("../sdk");
7
7
 
8
- function build(args) {
8
+ exports.command = function build(args) {
9
9
  const template_dir = ".";
10
10
  if (!fs.existsSync("template.yml")) {
11
11
  log.die("No template.yml file found in the current directory");
@@ -20,7 +20,7 @@ function build(args) {
20
20
  }
21
21
 
22
22
  sdk.buildRules(template_dir)
23
- .then((rules) => {
23
+ .then(async rules => {
24
24
  const script_by_key = new Map();
25
25
  for (const rule of rules) script_by_key.set(rule.key, rule.script);
26
26
 
@@ -32,17 +32,15 @@ function build(args) {
32
32
  scripts_to_run.push(script_by_key.get(key));
33
33
  }
34
34
 
35
- let p = Promise.resolve();
36
- for (let script of scripts_to_run) {
37
- p = p.then(() => sdk.runBuildCommand(template_dir, script, args.env));
35
+ for (const script of scripts_to_run) {
36
+ await sdk.runBuildCommand(template_dir, script, args.env);
38
37
  }
39
- return p;
40
38
  })
41
39
  .then(() => log.victory("Done!"))
42
40
  .catch((error) => log.die("Failed to build template", error.message, error.stack));
43
- }
41
+ };
44
42
 
45
- build.help = `
43
+ exports.help = `
46
44
  flourish build [options] [build rules...]
47
45
 
48
46
  Build the template in the current directory.
@@ -61,5 +59,3 @@ Options:
61
59
  Set the NODE_ENV environment variable to the specified value before running
62
60
  the build script.
63
61
  `;
64
-
65
- module.exports = build;
package/lib/cmd/delete.js CHANGED
@@ -3,7 +3,7 @@
3
3
  var log = require("../log"),
4
4
  sdk = require("../sdk");
5
5
 
6
- function _delete(args, server_opts) {
6
+ exports.command = function _delete(args) {
7
7
  let template_id = args._[1],
8
8
  template_version = args._[2];
9
9
 
@@ -14,7 +14,7 @@ function _delete(args, server_opts) {
14
14
  template_id = args.as + "/" + template_id;
15
15
  }
16
16
 
17
- sdk.request(server_opts, "template/delete", { id: template_id, version: template_version, force: !!args.force })
17
+ sdk.request(args, "template/delete", { id: template_id, version: template_version, force: !!args.force })
18
18
  .then(() => {
19
19
  if (template_version) {
20
20
  log.success(`Deleted template ${template_id} version ${template_version}`);
@@ -27,9 +27,9 @@ function _delete(args, server_opts) {
27
27
  if (args.debug) log.die("Failed to delete template", error.message, error.stack);
28
28
  else log.die("Failed to delete template", error.message);
29
29
  });
30
- }
30
+ };
31
31
 
32
- _delete.help = `
32
+ exports.help = `
33
33
  flourish delete [--force] template_id version
34
34
 
35
35
  Deletes the specified template from the server, assuming it has previously
@@ -44,5 +44,3 @@ If the template is in use by users other than you, it will not be possible
44
44
  to delete it. If you have used it, you can pass the --force flag to delete
45
45
  the template and associated visualisations.
46
46
  `;
47
-
48
- module.exports = _delete;
package/lib/cmd/help.js CHANGED
@@ -4,7 +4,7 @@ var path = require("path"),
4
4
 
5
5
  log = require("../log");
6
6
 
7
- function help(args) {
7
+ exports.command = function help(args) {
8
8
  const topic = args._[args._[0] === "help" ? 1 : 0] || "help";
9
9
 
10
10
  if (topic.indexOf(path.sep) == -1
@@ -18,9 +18,9 @@ function help(args) {
18
18
  log.die("No such help topic: " + topic);
19
19
  }
20
20
  }
21
- }
21
+ };
22
22
 
23
- help.help = `
23
+ exports.help = `
24
24
  Commands:
25
25
  flourish assign-version-number [template id] version
26
26
  flourish build [build rules...]
@@ -43,5 +43,3 @@ Type “flourish help [command]” for more on a particular command.
43
43
  To get started, use “flourish new” to create a new template and
44
44
  “flourish run” to run it.
45
45
  `;
46
-
47
- module.exports = help;
@@ -9,7 +9,7 @@ function byVersion(a, b) {
9
9
  return semver.cmp(semver.parse(a.version), semver.parse(b.version));
10
10
  }
11
11
 
12
- function history(args, server_opts) {
12
+ exports.command = function history(args) {
13
13
  const username_template_id = args._[1];
14
14
  if (!username_template_id) {
15
15
  log.die("Please specify a template id. E.g. flourish history my-template");
@@ -28,7 +28,7 @@ function history(args, server_opts) {
28
28
  else if (username_template_id) {
29
29
  template_id = username_template_id;
30
30
  }
31
- sdk.request(server_opts, "template/history", { username, id: template_id })
31
+ sdk.request(args, "template/history", { username, id: template_id })
32
32
  .then((result) => {
33
33
  const template_versions = result.sort(byVersion);
34
34
 
@@ -40,9 +40,9 @@ function history(args, server_opts) {
40
40
  }
41
41
  })
42
42
  .catch((error) => log.die("Failed to list template history", error.message, error.stack));
43
- }
43
+ };
44
44
 
45
- history.help = `
45
+ exports.help = `
46
46
  flourish history [template id]
47
47
 
48
48
  List the version numbers of a published template.
@@ -55,5 +55,3 @@ With the --full option, prints all the template metadata in JSON format.
55
55
 
56
56
  This command requires you to be logged in to an account.
57
57
  `;
58
-
59
- module.exports = history;
package/lib/cmd/list.js CHANGED
@@ -16,7 +16,7 @@ function byExternalIdAndVersion(a, b) {
16
16
  return semver.cmp(semver.parse(a.version), semver.parse(b.version));
17
17
  }
18
18
 
19
- function list(args, server_opts) {
19
+ exports.command = function list(args) {
20
20
  const username_template_id = args._[1];
21
21
  let username = args.as,
22
22
  template_id;
@@ -33,7 +33,7 @@ function list(args, server_opts) {
33
33
  else if (username_template_id) {
34
34
  template_id = username_template_id;
35
35
  }
36
- sdk.request(server_opts, "template/list", { username })
36
+ sdk.request(args, "template/list", { username })
37
37
  .then((result) => {
38
38
  let templates = result.templates;
39
39
 
@@ -55,9 +55,9 @@ function list(args, server_opts) {
55
55
  }
56
56
  })
57
57
  .catch((error) => log.die("Failed to list templates", error.message, error.stack));
58
- }
58
+ };
59
59
 
60
- list.help = `
60
+ exports.help = `
61
61
  flourish list [template id]
62
62
 
63
63
  List the ids and versions of your published templates.
@@ -69,5 +69,3 @@ With the --full option, prints all the template metadata in JSON format.
69
69
 
70
70
  This command requires you to be logged in to an account.
71
71
  `;
72
-
73
- module.exports = list;