@itwin/workspace-editor 3.0.0-dev.173 → 3.0.0-dev.177

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.
package/package.json CHANGED
@@ -3,21 +3,24 @@
3
3
  "private": false,
4
4
  "license": "MIT",
5
5
  "main": "lib/WorkspaceEditor.js",
6
- "version": "3.0.0-dev.173",
6
+ "version": "3.0.0-dev.177",
7
7
  "bin": {
8
8
  "WorkspaceEditor": "./lib/WorkspaceEditor.js"
9
9
  },
10
- "repository": {},
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/iTwin/itwinjs-core/tree/master/utils/workspace-editor"
13
+ },
11
14
  "dependencies": {
12
- "@itwin/core-bentley": "3.0.0-dev.173",
13
- "@itwin/core-common": "3.0.0-dev.173",
14
- "@itwin/core-backend": "3.0.0-dev.173",
15
+ "@itwin/core-bentley": "3.0.0-dev.177",
16
+ "@itwin/core-common": "3.0.0-dev.177",
17
+ "@itwin/core-backend": "3.0.0-dev.177",
15
18
  "glob": "^7.1.2",
16
19
  "yargs": "^16.0.0"
17
20
  },
18
21
  "devDependencies": {
19
- "@itwin/build-tools": "3.0.0-dev.173",
20
- "@itwin/eslint-plugin": "3.0.0-dev.173",
22
+ "@itwin/build-tools": "3.0.0-dev.177",
23
+ "@itwin/eslint-plugin": "3.0.0-dev.177",
21
24
  "@types/chai": "^4.1.4",
22
25
  "@types/mocha": "^8.2.2",
23
26
  "@types/yargs": "^12.0.5",
@@ -41,6 +44,7 @@
41
44
  "docs": "",
42
45
  "lint": "eslint --max-warnings 0 \"./src/**/*.ts\" 1>&2",
43
46
  "start": "node ./lib/Main.js",
44
- "test": "mocha"
45
- }
47
+ "test": ""
48
+ },
49
+ "readme": "# WorkspaceEditor\r\n\r\n**WorkspaceEditor** is a command line utility for creating and editing `WorkspaceResources` in iTwin `WorkspaceDb`s, and for uploading and downloading `WorkspaceDb`s to cloud `WorkspaceContainer`s.\r\n\r\nAn iTwin `WorkspaceDb` may hold many `WorkSpaceResources`, each with a `WorkspaceResourceName` and `WorkspaceResourceType`. `WorkspaceEditor` adds, updates, deletes, and extracts *local files* into/from a `WorkspaceDb`.\r\n\r\n## Workspace Resource Types\r\n\r\nThere are 3 `WorkspaceResourceType`s that may be accessed by `@itwin-backend` applications at runtime via the `WorkspaceContainer` api:\r\n\r\n 1. `string` accessed via the `getString` method\r\n 2. `blob` binary data accessed via the `getBlob` method\r\n 3. `file` extracted to a local file via the `getFile` method\r\n\r\nSeveral `WorkspaceEditor` commands require a `--type` argument to specify which `WorkspaceResourceType` to use.\r\n\r\n## The WorkspaceContainer Directory\r\n\r\n`WorkspaceDb`s are located by iTwin.js inside a `WorkspaceContainer` subdirectory within the `WorkspaceContainerDir` directory. `WorkspaceContainerDir` is specified as a directory name in the `workspace.containerDir` member on the `configuration` argument of `IModelHost.startup`. The default value is `%localappdata%/iTwin/Workspace`. WorkspaceEditor will normally create and edit `WorkspaceDb`s in the default directory, but if you wish to use a different directory, supply the `--directory` option to specify a different `WorkspaceContainerDir` location.\r\n\r\n## Workspace dbName\r\n\r\nThe WorkspaceEditor commands all take a `dbName` option to specify the `WorkspaceDb` on which to operate. The WorkspaceDb is located inside the `WorkspaceContainerId` specified with the --containerId argument. `WorkspaceDbName`s must be less than 255 characters, may not have leading or trailing whitespace, and may not use any reserved path specification characters (see documentation for `WorkspaceDbName` for details.) The `WorkspaceDb` filename is formed via: `${WorkspaceContainerDir}/${WorkspaceContainerId}/${WorkspaceDbName}.itwin-workspace`.\r\n\r\n## WorkspaceEditor Config file\r\n\r\n`WorkspaceEditor` accepts the `--config` option to specify the name of a JSON file that holds values for `WorkspaceEditor` options. By default, `WorkspaceEditor` looks in the current directory for a file named `workspaceEditor.json`.\r\n\r\nExample:\r\n\r\n```sh\r\n> WorkspaceEdit --config myConfig.json list db1\r\n...\r\n```\r\n\r\n```json\r\n> cat myConfig.json\r\n{\r\n \"directory\": \"d:/projData/112/\",\r\n \"containerId\": \"proj112\",\r\n \"accountName\": \"smsblob1\",\r\n \"sasToken\": \"<valid token here>\"\r\n}\r\n```\r\n\r\n> Note: config files **must** have a `.json` extension.\r\n\r\n## WorkspaceEditor Commands\r\n\r\nThe following WorkspaceEditor commands are available:\r\n\r\n### Create\r\n\r\nCreate a new empty `WorkspaceDb`.\r\n\r\nExample:\r\n\r\n```sh\r\n> WorkspaceEdit create proj\r\ncreated WorkspaceDb C:\\Users\\User.Name\\AppData\\Local\\iTwin\\Workspace\\proj112\\proj.itwin-workspace\r\n```\r\n\r\n### Add\r\n\r\nAdd one or more local files as resources into a `WorkspaceDb`.\r\n\r\n`--type` specifies the type of resource(s) to add. Required\r\n`--name` specifies the name of the resource. Defaults to the name of the local file.\r\n`--root` specifies a root directory when adding multiple files. The parts of the path after the root are saved in the resource name (see example below.)\r\n`--update` indicates that an existing resource should be updated (i.e. replaced.)\r\n\r\n> Note: `--name` is only applicable when adding a single file.\r\n\r\nExamples:\r\n\r\n```sh\r\n> WorkspaceEditor add proj -n equipment-data D:\\data\\equip.dat\r\nWorkspaceDb [C:\\Users\\User.Name\\AppData\\Local\\iTwin\\Workspace\\proj112\\proj.itwin-workspace]\r\n added \"D:\\data\\equip.dat\" as file resource [equipment-data]\r\n```\r\n\r\n```sh\r\n> WorkspaceEditor add proj -string *.json\r\nWorkspaceDb [C:\\Users\\User.Name\\AppData\\Local\\iTwin\\Workspace\\proj112\\proj.itwin-workspace]\r\n added \"specs.json\" as string resource [specs.json]\r\n added \"vendor.json\" as string resource [vendor.json]\r\n ```\r\n\r\n```sh\r\n > WorkspaceEditor add proj -t blob -r d:\\projData\\112\\ **\\*.dict\r\nWorkspaceDb [C:\\Users\\User.Name\\AppData\\Local\\iTwin\\Workspace\\proj112\\proj.itwin-workspace]\r\n added \"d:\\projData\\112\\TernKit\\KDEO5814.dict\" as blob resource [TernKit/KDEO5814.dict]\r\n added \"d:\\projData\\112\\TernKit\\KDEO5815.dict\" as blob resource [TernKit/KDEO5815.dict]\r\n added \"d:\\projData\\112\\UniSpace\\KDEO5814.dict\" as blob resource [UniSpace/KDEO5814.dict]\r\n added \"d:\\projData\\112\\UniSpace\\KDEO5815.dict\" as blob resource [UniSpace/KDEO5815.dict]\r\n added \"d:\\projData\\112\\Sparks\\KDEO5814.dict\" as blob resource [Sparks/KDEO5814.dict]\r\n added \"d:\\projData\\112\\Sparks\\KDEO5815.dict\" as blob resource [Sparks/KDEO5815.dict]\r\n added \"d:\\projData\\112\\Sparks\\KDEO5816.dict\" as blob resource [Sparks/KDEO5816.dict]\r\n ```\r\n\r\n### List\r\n\r\nList the contents of a `WorkspaceDb`. By default it will show all 3 resource types. To limit the output to specific types, supply the `--strings`, `--blobs`, or `--files` options.\r\n\r\nExamples:\r\n\r\n```sh\r\n> WorkspaceEditor list proj\r\nWorkspaceDb [C:\\Users\\User.Name\\AppData\\Local\\iTwin\\Workspace\\proj112\\proj.itwin-workspace]\r\n strings:\r\n name=[specs.json], size=12050\r\n name=[vendor.json], size=31335\r\n blobs:\r\n name=[TernKit/KDEO5814.dict], size=144221\r\n name=[TernKit/KDEO5815.dict], size=89600\r\n name=[UniSpace/KDEO5814.dict], size=144384\r\n name=[UniSpace/KDEO5815.dict], size=89600\r\n name=[Sparks/KDEO5814.dict], size=144384\r\n name=[Sparks/KDEO5815.dict], size=109056\r\n name=[Sparks/KDEO5816.dict], size=70144\r\n files:\r\n name=[equipment-data], size=14484, ext=\"dat\", date=Thu Mar 12 2015 13:52:51 GMT-0400\r\n```\r\n\r\n```sh\r\n> WorkspaceEditor list proj --strings\r\nWorkspaceDb [C:\\Users\\User.Name\\AppData\\Local\\iTwin\\Workspace\\proj112\\proj.itwin-workspace]\r\n strings:\r\n name=[specs.json], size=12050\r\n name=[vendor.json], size=31335\r\n```\r\n\r\n### Extract\r\n\r\nExtract a `WorkspaceResource` from a `WorkspaceDb` into a local file.\r\n\r\nExample:\r\n```sh\r\n> WorkspaceEditor extract proj -t blob UniSpace/KDEO5815.dict d:\\temp\\kd.dict\r\nWorkspaceDb [C:\\Users\\User.Name\\AppData\\Local\\iTwin\\Workspace\\proj112\\proj.itwin-workspace]\r\n blob resource [UniSpace/KDEO5815.dict] extracted to \"d:\\temp\\kd.dict\"\r\n```\r\n\r\n### Delete\r\n\r\nDelete an existing `WorkspaceResource` from a `WorkspaceDb`.\r\n\r\nExample:\r\n```sh\r\n> WorkspaceEditor delete proj -t blob UniSpace/KDEO5815.dict\r\nWorkspaceDb [C:\\Users\\User.Name\\AppData\\Local\\iTwin\\Workspace\\proj112\\proj.itwin-workspace]\r\n deleted blob resource [UniSpace/KDEO5815.dict]\r\n```\r\n\r\n### Vacuum\r\n\r\n[Vacuum](https://www.sqlite.org/lang_vacuum.html) a `WorkspaceDb`. This can make a `WorkspaceDb` smaller and more efficient to access.\r\n\r\nExample:\r\n```sh\r\n> WorkspaceEditor vacuum proj\r\nWorkspaceDb [C:\\Users\\User.Name\\AppData\\Local\\iTwin\\Workspace\\proj112\\proj.itwin-workspace] vacuumed\r\n```\r\n"
46
50
  }
@@ -9,7 +9,8 @@ import { join } from "path";
9
9
  import * as readline from "readline";
10
10
  import * as Yargs from "yargs";
11
11
  import {
12
- CloudSqlite, EditableWorkspaceDb, IModelHost, IModelHostConfiguration, IModelJsFs, ITwinWorkspaceDb, WorkspaceContainerId, WorkspaceDbName,
12
+ CloudSqlite,
13
+ EditableWorkspaceDb, IModelHost, IModelHostConfiguration, IModelJsFs, ITwinWorkspaceDb, WorkspaceContainerId, WorkspaceDbName,
13
14
  WorkspaceResourceName,
14
15
  } from "@itwin/core-backend";
15
16
  import { DbResult, StopWatch } from "@itwin/core-bentley";
@@ -51,7 +52,7 @@ interface ResourceOption extends WorkspaceDbOpt {
51
52
  }
52
53
 
53
54
  /** Options for deleting resources from a WorkspaceDb */
54
- interface DeleteResourceOpts extends ResourceOption {
55
+ interface RemoveResourceOpts extends ResourceOption {
55
56
  rscName: WorkspaceResourceName;
56
57
  }
57
58
 
@@ -196,8 +197,8 @@ async function extractResource(args: ExtractResourceOpts) {
196
197
  });
197
198
  }
198
199
 
199
- /** Delete a single resource from a WorkspaceDb */
200
- async function deleteResource(args: DeleteResourceOpts) {
200
+ /** Remove a single resource from a WorkspaceDb */
201
+ async function removeResource(args: RemoveResourceOpts) {
201
202
  editWorkspace(args, (wsFile, args) => {
202
203
  if (args.type === "string")
203
204
  wsFile.removeString(args.rscName);
@@ -205,7 +206,7 @@ async function deleteResource(args: DeleteResourceOpts) {
205
206
  wsFile.removeBlob(args.rscName);
206
207
  else
207
208
  wsFile.removeFile(args.rscName);
208
- console.log(` deleted ${args.type} resource [${args.rscName}]`);
209
+ console.log(` removed ${args.type} resource [${args.rscName}]`);
209
210
  });
210
211
  }
211
212
 
@@ -326,10 +327,10 @@ async function main() {
326
327
  handler: runCommand(extractResource),
327
328
  });
328
329
  Yargs.command({
329
- command: "deleteResource <dbName> <rscName>",
330
- describe: "delete a resource from a WorkspaceDb",
330
+ command: "remove <dbName> <rscName>",
331
+ describe: "remove a resource from a WorkspaceDb",
331
332
  builder: { type },
332
- handler: runCommand(deleteResource),
333
+ handler: runCommand(removeResource),
333
334
  });
334
335
  Yargs.command({
335
336
  command: "upload <dbName>",
@@ -349,7 +350,7 @@ async function main() {
349
350
  handler: runCommand(downloadWorkspaceDb),
350
351
  });
351
352
  Yargs.command({
352
- command: "deleteDb <dbName>",
353
+ command: "delete <dbName>",
353
354
  describe: "delete a WorkspaceDb from cloud storage",
354
355
  handler: runCommand(deleteWorkspaceDb),
355
356
  });