-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
create-package-files
84 lines (72 loc) · 2.5 KB
/
create-package-files
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
# Create CommonJS package.json
cat >dist/cjs/package.json <<JSON
{
"type": "commonjs",
"types": "../types/index.d.ts",
"browser": {
"./index.js": "./browser.js",
"./ipc/index.js": "./ipc/browser.js",
"./promise-fs/index.js": "./promise-fs/browser.js",
"./storage/binary/index.js": "./storage/binary/browser.js",
"./storage/mssql/index.js": "./storage/mssql/browser.js",
"./storage/sqlite/index.js": "./storage/sqlite/browser.js",
"./data-index/index.js": "./data-index/browser.js",
"./btree/index.js": "./btree/browser.js"
}
}
JSON
# Write typings to support Node16 module resolution
cat >dist/cjs/index.d.ts <<TYPESCRIPT
export * from '../types/index.js';
TYPESCRIPT
# Create ESM package.json
cat >dist/esm/package.json <<JSON
{
"type": "module",
"types": "../types/index.d.ts",
"browser": {
"./index.js": "./browser.js",
"./ipc/index.js": "./ipc/browser.js",
"./promise-fs/index.js": "./promise-fs/browser.js",
"./storage/binary/index.js": "./storage/binary/browser.js",
"./storage/mssql/index.js": "./storage/mssql/browser.js",
"./storage/sqlite/index.js": "./storage/sqlite/browser.js",
"./data-index/index.js": "./data-index/browser.js",
"./btree/index.js": "./btree/browser.js"
}
}
JSON
# Write typings to support Node16 module resolution
cat >dist/esm/index.d.ts <<TYPESCRIPT
export * from '../types/index.js';
TYPESCRIPT
# Write example file for runkit
cat >dist/runkit.js <<JAVASCRIPT
const { AceBase } = require('acebase');
// Open or create database:
const db = new AceBase('mydb', { logLevel: 'error' });
// Set data at "runkit/test"
await db.ref('runkit/test').set({
text: 'This is a test',
created: new Date(),
});
// Update "text" child of "runkit/test", create "modified" child
await db.ref('runkit/test').update({
text: 'Updated text with a parent node update',
modified: new Date(),
});
// Overwrite "runkit/test/text"
await db.ref('runkit/test/text').set('Updated text by setting it');
// Get all data stored at "runkit/test"
const snapshot = await db.ref('runkit/test').get();
console.log('Value stored at "runkit/test":');
console.log(snapshot.val());
// Transactional update on "runkit/test/counter"
await db.ref('runkit/test/counter').transaction(snapshot => {
const val = snapshot.exists() ? snapshot.val() : 0;
return val + 1; // new value for "counter" property
});
// Remove "runkit"
await db.ref('runkit').remove();
JAVASCRIPT