@sjcrh/proteinpaint-rust 2.120.2-0 → 2.121.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.
package/README.md CHANGED
@@ -2,13 +2,11 @@
2
2
 
3
3
  This directory holds the source code for rust-compiled utilities.
4
4
 
5
-
6
5
  ## Code layout
7
6
 
8
7
  All source code files should be directly under the `src/` directory. For a source
9
8
  code file to be compiled, create a `[[bin]]` entry for it in the Cargo.toml file:
10
9
 
11
-
12
10
  ```toml
13
11
  [[bin]]
14
12
  name="tool0"
@@ -27,10 +25,10 @@ which goes against rust cargo's assumptions of having source code under `src/bin
27
25
  ## Using from nodejs
28
26
 
29
27
  ```js
30
- // assuming a js file from server/src
31
- const run_rust = require('@sjcrh/proteinpaint-rust').run_rust
32
- // or
33
- // import * as utils from './utils'
28
+ // Assuming a js or ts file from server/src
29
+
30
+ import { run_rust } from '@sjcrh/proteinpaint-rust'
31
+
34
32
 
35
33
  // 'indel' may be replaced by any binary name as specified in Cargo.toml
36
34
  const out = await run_rust('indel', input_data)
@@ -39,8 +37,10 @@ const out = await run_rust('indel', input_data)
39
37
  ## Test
40
38
 
41
39
  From the `proteinpaint/server` directory,
40
+
42
41
  ```bash
43
42
  npx test
43
+ npx tsc
44
44
  ```
45
45
 
46
46
  ## Build
@@ -1,12 +1,16 @@
1
- const https = require('https')
2
- const fs = require('fs')
3
- const os = require('os')
4
- const path = require('path')
5
- const { exec } = require('child_process')
6
- const tar = require('tar')
1
+ // Import necessary modules
2
+ import https from 'https'
3
+ import fs from 'fs'
4
+ import os from 'os'
5
+ import path from 'path'
6
+ import { exec } from 'child_process'
7
+ import * as tar from 'tar'
7
8
 
8
- // Read package.json to get version and pp_release_tag
9
- const packageJson = require(path.join(__dirname, 'package.json'))
9
+ // Setting up directory name
10
+ const __dirname = import.meta.dirname
11
+
12
+ // Read package.json
13
+ const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'))
10
14
  const { version, pp_release_tag } = packageJson
11
15
 
12
16
  const targetDirectory = './target/release'
package/index.js CHANGED
@@ -1,18 +1,20 @@
1
- const fs = require('fs')
2
- const path = require('path'),
3
- { spawn, exec } = require('child_process'),
4
- Readable = require('stream').Readable,
5
- Transform = require('stream').Transform,
6
- { promisify } = require('util')
1
+ // Import necessary modules
2
+ import fs from 'fs'
3
+ import path from 'path'
4
+ import { spawn, exec } from 'child_process'
5
+ import { Readable, Transform } from 'stream'
6
+ import { promisify } from 'util'
7
+
8
+ const __dirname = import.meta.dirname
7
9
 
8
10
  const execPromise = promisify(exec)
9
11
 
10
- // check if rust binary directory exists and is not empty
12
+ // Check if rust binary directory exists and is not empty
11
13
  const binaryDir = path.join(__dirname, '/target/release/')
12
14
  if (!fs.existsSync(binaryDir)) throw `missing rust binary directory='${binaryDir}'`
13
15
  if (!fs.readdirSync(binaryDir).length) throw `empty rust binary directory='${binaryDir}'`
14
16
 
15
- exports.run_rust = function (binfile, input_data) {
17
+ export function run_rust(binfile, input_data) {
16
18
  return new Promise((resolve, reject) => {
17
19
  const binpath = path.join(__dirname, '/target/release/', binfile)
18
20
  const ps = spawn(binpath)
@@ -52,7 +54,7 @@ exports.run_rust = function (binfile, input_data) {
52
54
  })
53
55
  }
54
56
 
55
- exports.stream_rust = function (binfile, input_data, emitJson) {
57
+ export function stream_rust(binfile, input_data, emitJson) {
56
58
  const binpath = path.join(__dirname, '/target/release/', binfile)
57
59
 
58
60
  const ps = spawn(binpath)
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
- "version": "2.120.2-0",
2
+ "version": "2.121.0",
3
3
  "name": "@sjcrh/proteinpaint-rust",
4
+ "type": "module",
4
5
  "description": "Rust-based utilities for proteinpaint",
5
6
  "main": "index.js",
6
7
  "bin": {
@@ -38,5 +39,5 @@
38
39
  "devDependencies": {
39
40
  "tape": "^5.2.2"
40
41
  },
41
- "pp_release_tag": "v2.120.2-0"
42
+ "pp_release_tag": "v2.121.0"
42
43
  }