pagan-artifact 0.3.0 → 0.3.1
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/bin/art.js +1 -1
- package/branching/index.js +2 -2
- package/caches/index.js +6 -4
- package/changes/index.js +2 -2
- package/contributions/index.js +1 -1
- package/index.js +2 -2
- package/package.json +1 -1
- package/setup/index.js +8 -4
- package/utils/getStateByHash/index.js +1 -1
- package/workflow/index.js +90 -85
package/bin/art.js
CHANGED
package/branching/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* art - Modern version control.
|
|
3
|
-
* Module: Branching (v0.3.
|
|
3
|
+
* Module: Branching (v0.3.1)
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const fs = require('fs');
|
|
@@ -297,7 +297,7 @@ function checkout (branchName, { force = false } = {}) {
|
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
module.exports = {
|
|
300
|
-
__libraryVersion: '0.3.
|
|
300
|
+
__libraryVersion: '0.3.1',
|
|
301
301
|
__libraryAPIName: 'Branching',
|
|
302
302
|
branch,
|
|
303
303
|
checkout,
|
package/caches/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* art - Modern version control.
|
|
3
|
-
* Module: Caches (v0.3.
|
|
3
|
+
* Module: Caches (v0.3.1)
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const fs = require('fs');
|
|
@@ -15,7 +15,7 @@ const MAX_PART_SIZE = 32000000;
|
|
|
15
15
|
* Helper to load all changes from a paginated directory (Stage or Stash).
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
function getPaginatedChanges(dirPath) {
|
|
18
|
+
function getPaginatedChanges (dirPath) {
|
|
19
19
|
const manifestPath = path.join(dirPath, 'manifest.json');
|
|
20
20
|
|
|
21
21
|
if (!fs.existsSync(dirPath) || !fs.existsSync(manifestPath)) {
|
|
@@ -28,6 +28,7 @@ function getPaginatedChanges(dirPath) {
|
|
|
28
28
|
|
|
29
29
|
for (const partName of manifest.parts) {
|
|
30
30
|
const partPath = path.join(dirPath, partName);
|
|
31
|
+
|
|
31
32
|
if (fs.existsSync(partPath)) {
|
|
32
33
|
const partData = JSON.parse(fs.readFileSync(partPath, 'utf8'));
|
|
33
34
|
|
|
@@ -205,9 +206,10 @@ function stash ({ pop = false, list = false } = {}) {
|
|
|
205
206
|
if (fs.existsSync(stageDir)) {
|
|
206
207
|
fs.rmSync(stageDir, { recursive: true, force: true });
|
|
207
208
|
}
|
|
209
|
+
|
|
208
210
|
checkout(artJson.active.branch, { force: true });
|
|
209
211
|
|
|
210
|
-
return `Saved working directory changes to
|
|
212
|
+
return `Saved working directory changes to stash_${timestamp} and reverted to clean state.`;
|
|
211
213
|
}
|
|
212
214
|
|
|
213
215
|
function reset (hash) {
|
|
@@ -259,7 +261,7 @@ function rm (filePath) {
|
|
|
259
261
|
}
|
|
260
262
|
|
|
261
263
|
module.exports = {
|
|
262
|
-
__libraryVersion: '0.3.
|
|
264
|
+
__libraryVersion: '0.3.1',
|
|
263
265
|
__libraryAPIName: 'Caches',
|
|
264
266
|
stash,
|
|
265
267
|
reset,
|
package/changes/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* art - Modern version control.
|
|
3
|
-
* Module: Changes (v0.3.
|
|
3
|
+
* Module: Changes (v0.3.1)
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const fs = require('fs');
|
|
@@ -136,7 +136,7 @@ function diff () {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
module.exports = {
|
|
139
|
-
__libraryVersion: '0.3.
|
|
139
|
+
__libraryVersion: '0.3.1',
|
|
140
140
|
__libraryAPIName: 'Changes',
|
|
141
141
|
log,
|
|
142
142
|
diff
|
package/contributions/index.js
CHANGED
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* art - Modern version control.
|
|
3
|
-
* Core Library Entry Point (v0.3.
|
|
3
|
+
* Core Library Entry Point (v0.3.1)
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const Setup = require('./setup');
|
|
@@ -50,7 +50,7 @@ const art = {
|
|
|
50
50
|
|
|
51
51
|
// Metadata
|
|
52
52
|
|
|
53
|
-
version: '0.3.
|
|
53
|
+
version: '0.3.1',
|
|
54
54
|
modules: [
|
|
55
55
|
Setup.__libraryAPIName,
|
|
56
56
|
Workflow.__libraryAPIName,
|
package/package.json
CHANGED
package/setup/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* art - Modern version control.
|
|
3
|
-
* Module: Setup (v0.3.
|
|
3
|
+
* Module: Setup (v0.3.1)
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const fs = require('fs');
|
|
@@ -10,6 +10,7 @@ const pkg = require('../package.json');
|
|
|
10
10
|
const shouldIgnore = require('../utils/shouldIgnore');
|
|
11
11
|
|
|
12
12
|
const ARTIFACT_HOST = pkg.artConfig.host || 'http://localhost:1337';
|
|
13
|
+
const MAX_PART_CHARS = 32000000;
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Internal helper to create the .art directory tree.
|
|
@@ -43,7 +44,7 @@ function init (directoryPath = process.cwd()) {
|
|
|
43
44
|
const artDirectory = path.join(directoryPath, '.art');
|
|
44
45
|
|
|
45
46
|
if (fs.existsSync(artDirectory)) {
|
|
46
|
-
return `Reinitialized existing art repository in ${artDirectory}
|
|
47
|
+
return `Reinitialized existing art repository in ${artDirectory}.`;
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
ensureDirStructure(artDirectory);
|
|
@@ -51,19 +52,20 @@ function init (directoryPath = process.cwd()) {
|
|
|
51
52
|
const files = fs.readdirSync(directoryPath, { recursive: true })
|
|
52
53
|
.filter(f => {
|
|
53
54
|
const isInternal = f === '.art' || f.startsWith('.art' + path.sep);
|
|
55
|
+
|
|
54
56
|
return !isInternal && !shouldIgnore(f);
|
|
55
57
|
});
|
|
56
58
|
|
|
57
59
|
const rootMasterManifest = { parts: [] };
|
|
60
|
+
|
|
58
61
|
let currentPartFiles = [];
|
|
59
62
|
let currentPartChars = 0;
|
|
60
|
-
const MAX_PART_CHARS = 32000000;
|
|
61
63
|
|
|
62
64
|
const saveManifestPart = () => {
|
|
63
65
|
if (currentPartFiles.length === 0) return;
|
|
64
66
|
|
|
65
67
|
const partIndex = rootMasterManifest.parts.length;
|
|
66
|
-
const partName = `manifest.part.${
|
|
68
|
+
const partName = `manifest.part.${partIndex}.json`;
|
|
67
69
|
const partPath = path.join(artDirectory, 'root', partName);
|
|
68
70
|
|
|
69
71
|
fs.writeFileSync(
|
|
@@ -187,10 +189,12 @@ async function clone (repoSlug, providedToken = null) {
|
|
|
187
189
|
});
|
|
188
190
|
|
|
189
191
|
const partData = await partRes.json();
|
|
192
|
+
|
|
190
193
|
fs.writeFileSync(path.join(artPath, 'root', partName), JSON.stringify(partData, null, 2));
|
|
191
194
|
|
|
192
195
|
for (const file of partData.files) {
|
|
193
196
|
const workingPath = path.join(targetPath, file.path);
|
|
197
|
+
|
|
194
198
|
fs.mkdirSync(path.dirname(workingPath), { recursive: true });
|
|
195
199
|
fs.writeFileSync(workingPath, file.content);
|
|
196
200
|
}
|
package/workflow/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* art - Modern version control.
|
|
3
|
-
* Module: Workflow (v0.3.
|
|
3
|
+
* Module: Workflow (v0.3.1)
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const fs = require('fs');
|
|
@@ -105,119 +105,124 @@ function status () {
|
|
|
105
105
|
* Updates or creates a JSON diff in the stage directory.
|
|
106
106
|
*/
|
|
107
107
|
|
|
108
|
-
function add (targetPath) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
function add (targetPath) {
|
|
109
|
+
const root = process.cwd();
|
|
110
|
+
const artPath = path.join(root, '.art');
|
|
111
|
+
const stageDir = path.join(artPath, 'stage');
|
|
112
|
+
const artJsonPath = path.join(artPath, 'art.json');
|
|
113
|
+
const fullPath = path.resolve(root, targetPath);
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
if (!fs.existsSync(fullPath)) {
|
|
116
|
+
throw new Error(`Path does not exist: ${targetPath}`);
|
|
117
|
+
}
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
const artJson = JSON.parse(fs.readFileSync(artJsonPath, 'utf8'));
|
|
120
|
+
const activeState = getStateByHash(artJson.active.branch, artJson.active.parent) || {};
|
|
121
|
+
const currentStaged = getStagedChanges(artPath);
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
const stats = fs.statSync(fullPath);
|
|
124
|
+
const relativeTarget = path.relative(root, fullPath);
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
if (!stats.isDirectory() && shouldIgnore(relativeTarget) && !activeState[relativeTarget]) {
|
|
127
|
+
return `${relativeTarget} is being ignored.`;
|
|
128
|
+
}
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
let filesToProcess = [];
|
|
131
131
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
132
|
+
if (stats.isDirectory()) {
|
|
133
|
+
filesToProcess = fs.readdirSync(fullPath, { recursive: true })
|
|
134
|
+
.filter(f => {
|
|
135
|
+
const absF = path.join(fullPath, f);
|
|
136
|
+
const relF = path.relative(root, absF);
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
138
|
+
return !fs.statSync(absF).isDirectory() && !relF.startsWith('.art') && (!shouldIgnore(relF) || !!activeState[relF]);
|
|
139
|
+
})
|
|
140
|
+
.map(f => path.relative(root, path.join(fullPath, f)));
|
|
141
|
+
} else {
|
|
142
|
+
filesToProcess = [relativeTarget];
|
|
143
|
+
}
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
if (filesToProcess.length === 0) return "No changes to add.";
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
for (const relPath of filesToProcess) {
|
|
148
|
+
const currentContent = fs.readFileSync(path.join(root, relPath), 'utf8');
|
|
149
|
+
const previousContent = activeState[relPath];
|
|
150
150
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
if (previousContent === undefined) {
|
|
152
|
+
currentStaged[relPath] = { type: 'createFile', content: currentContent };
|
|
153
|
+
} else if (currentContent !== previousContent) {
|
|
154
|
+
let start = 0;
|
|
155
155
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
156
|
+
while (start < previousContent.length && start < currentContent.length && previousContent[start] === currentContent[start]) {
|
|
157
|
+
start++;
|
|
158
|
+
}
|
|
159
159
|
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
let oldEnd = previousContent.length - 1;
|
|
161
|
+
let newEnd = currentContent.length - 1;
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
while (oldEnd >= start && newEnd >= start && previousContent[oldEnd] === currentContent[newEnd]) {
|
|
164
|
+
oldEnd--; newEnd--;
|
|
165
|
+
}
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
const operations = [];
|
|
168
|
+
const deletionLength = oldEnd - start + 1;
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
if (deletionLength > 0) {
|
|
171
|
+
operations.push({
|
|
172
|
+
type: 'delete',
|
|
173
|
+
position: start,
|
|
174
|
+
length: deletionLength,
|
|
175
|
+
content: previousContent.slice(start, oldEnd + 1)
|
|
176
|
+
});
|
|
177
|
+
}
|
|
173
178
|
|
|
174
|
-
|
|
179
|
+
const insertionContent = currentContent.slice(start, newEnd + 1);
|
|
175
180
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
181
|
+
if (insertionContent.length > 0) {
|
|
182
|
+
operations.push({ type: 'insert', position: start, content: insertionContent });
|
|
183
|
+
}
|
|
179
184
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
+
if (operations.length > 0) {
|
|
186
|
+
currentStaged[relPath] = operations;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
185
190
|
|
|
186
|
-
|
|
191
|
+
if (fs.existsSync(stageDir)) fs.rmSync(stageDir, { recursive: true, force: true });
|
|
187
192
|
|
|
188
|
-
|
|
193
|
+
fs.mkdirSync(stageDir, { recursive: true });
|
|
189
194
|
|
|
190
|
-
|
|
195
|
+
const stageParts = [];
|
|
191
196
|
|
|
192
|
-
|
|
193
|
-
|
|
197
|
+
let currentPartChanges = {};
|
|
198
|
+
let currentSize = 0;
|
|
194
199
|
|
|
195
|
-
|
|
196
|
-
|
|
200
|
+
const savePart = () => {
|
|
201
|
+
const partName = `part.${stageParts.length}.json`;
|
|
197
202
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
+
fs.writeFileSync(path.join(stageDir, partName), JSON.stringify({ changes: currentPartChanges }, null, 2));
|
|
204
|
+
stageParts.push(partName);
|
|
205
|
+
currentPartChanges = {};
|
|
206
|
+
currentSize = 0;
|
|
207
|
+
};
|
|
203
208
|
|
|
204
|
-
|
|
205
|
-
|
|
209
|
+
for (const [file, changes] of Object.entries(currentStaged)) {
|
|
210
|
+
const size = JSON.stringify(changes).length;
|
|
206
211
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
212
|
+
if (currentSize + size > MAX_PART_SIZE && Object.keys(currentPartChanges).length > 0) {
|
|
213
|
+
savePart();
|
|
214
|
+
}
|
|
210
215
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
216
|
+
currentPartChanges[file] = changes;
|
|
217
|
+
currentSize += size;
|
|
218
|
+
}
|
|
214
219
|
|
|
215
|
-
|
|
220
|
+
savePart();
|
|
216
221
|
|
|
217
|
-
|
|
222
|
+
fs.writeFileSync(path.join(stageDir, 'manifest.json'), JSON.stringify({ parts: stageParts }, null, 2));
|
|
218
223
|
|
|
219
|
-
|
|
220
|
-
}
|
|
224
|
+
return `Added ${filesToProcess.length} file(s) to stage.`;
|
|
225
|
+
}
|
|
221
226
|
|
|
222
227
|
/**
|
|
223
228
|
* Finalizes the paginated stage into a paginated commit structure.
|
|
@@ -297,7 +302,7 @@ function commit (message) {
|
|
|
297
302
|
}
|
|
298
303
|
|
|
299
304
|
module.exports = {
|
|
300
|
-
__libraryVersion: '0.3.
|
|
305
|
+
__libraryVersion: '0.3.1',
|
|
301
306
|
__libraryAPIName: 'Workflow',
|
|
302
307
|
status,
|
|
303
308
|
add,
|