gitsheets 0.22.0 → 0.22.3
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/commands/normalize.js +3 -3
- package/lib/Sheet.js +23 -17
- package/lib/path/Template.js +1 -0
- package/package.json +1 -1
package/commands/normalize.js
CHANGED
|
@@ -57,16 +57,16 @@ exports.handler = async function query({
|
|
|
57
57
|
try {
|
|
58
58
|
for await (const record of sheet.query()) {
|
|
59
59
|
const originalPath = record[Symbol.for('gitsheets-path')];
|
|
60
|
-
logger.info(`rewriting ${path.join(root, prefix, sheetName, originalPath)}.toml`);
|
|
60
|
+
logger.info(`rewriting ${path.join(root, prefix||'', sheetName, originalPath)}.toml`);
|
|
61
61
|
const { path: normalizedPath } = await sheet.upsert(record);
|
|
62
62
|
|
|
63
63
|
if (normalizedPath !== originalPath) {
|
|
64
|
-
logger.warn(`^- moved to ${path.join(root, prefix, sheetName, normalizedPath)}.toml`);
|
|
64
|
+
logger.warn(`^- moved to ${path.join(root, prefix||'', sheetName, normalizedPath)}.toml`);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
} catch (err) {
|
|
68
68
|
if (err.constructor.name == 'TomlError') {
|
|
69
|
-
logger.error(`failed to parse ${path.join(root, prefix, err.file)}\n${err.message}`);
|
|
69
|
+
logger.error(`failed to parse ${path.join(root, prefix||'', err.file)}\n${err.message}`);
|
|
70
70
|
process.exit(1);
|
|
71
71
|
}
|
|
72
72
|
|
package/lib/Sheet.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const v8 = require('v8');
|
|
2
|
+
// const v8 = require('v8');
|
|
3
3
|
const vm = require('vm');
|
|
4
4
|
const sortKeys = require('sort-keys');
|
|
5
5
|
const TOML = require('@iarna/toml');
|
|
@@ -40,7 +40,7 @@ class Sheet extends Configurable
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
#recordCache;
|
|
43
|
+
// #recordCache;
|
|
44
44
|
|
|
45
45
|
constructor ({ workspace, name, dataTree = null, configPath = null }) {
|
|
46
46
|
if (!workspace) {
|
|
@@ -57,7 +57,7 @@ class Sheet extends Configurable
|
|
|
57
57
|
this.configPath = configPath || `.gitsheets/${name}.toml`;
|
|
58
58
|
this.dataTree = dataTree || workspace.root;
|
|
59
59
|
|
|
60
|
-
this.#recordCache = new Map();
|
|
60
|
+
// this.#recordCache = new Map();
|
|
61
61
|
|
|
62
62
|
Object.freeze(this);
|
|
63
63
|
}
|
|
@@ -116,22 +116,28 @@ class Sheet extends Configurable
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
async readRecord (blob, path = null) {
|
|
119
|
-
|
|
119
|
+
/**
|
|
120
|
+
* caching is disabled for now, because v8.serialize doesn't
|
|
121
|
+
* preserve the custom Date classes that iarna/toml uses to
|
|
122
|
+
* preserve extended date types
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
// const cache = this.#recordCache.get(blob.hash);
|
|
120
126
|
|
|
121
127
|
let record;
|
|
122
128
|
|
|
123
|
-
if (cache) {
|
|
124
|
-
|
|
125
|
-
} else {
|
|
126
|
-
|
|
129
|
+
// if (cache) {
|
|
130
|
+
// record = v8.deserialize(cache);
|
|
131
|
+
// } else {
|
|
132
|
+
const toml = await blob.read();
|
|
127
133
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
+
try {
|
|
135
|
+
record = TOML.parse(toml);
|
|
136
|
+
} catch (err) {
|
|
137
|
+
err.file = path;
|
|
138
|
+
throw err;
|
|
134
139
|
}
|
|
140
|
+
// }
|
|
135
141
|
|
|
136
142
|
// annotate with gitsheets keys
|
|
137
143
|
record[RECORD_SHEET_KEY] = this.name;
|
|
@@ -140,9 +146,9 @@ class Sheet extends Configurable
|
|
|
140
146
|
}
|
|
141
147
|
|
|
142
148
|
// fill cache
|
|
143
|
-
if (!cache) {
|
|
144
|
-
|
|
145
|
-
}
|
|
149
|
+
// if (!cache) {
|
|
150
|
+
// this.#recordCache.set(blob.hash, toml);
|
|
151
|
+
// }
|
|
146
152
|
|
|
147
153
|
return record;
|
|
148
154
|
}
|
package/lib/path/Template.js
CHANGED