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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  /**
4
4
  * art - Modern version control.
5
- * CLI (v0.3.0)
5
+ * CLI (v0.3.1)
6
6
  */
7
7
 
8
8
  const art = require('../index.js');
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * art - Modern version control.
3
- * Module: Branching (v0.3.0)
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.0',
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.0)
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 paginated stash_${timestamp} and reverted to clean state.`;
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.0',
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.0)
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.0',
139
+ __libraryVersion: '0.3.1',
140
140
  __libraryAPIName: 'Changes',
141
141
  log,
142
142
  diff
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * art - Modern version control.
3
- * Module: Contributions (v0.3.0)
3
+ * Module: Contributions (v0.3.1)
4
4
  */
5
5
 
6
6
  const fs = require('fs');
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * art - Modern version control.
3
- * Core Library Entry Point (v0.3.0)
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.0',
53
+ version: '0.3.1',
54
54
  modules: [
55
55
  Setup.__libraryAPIName,
56
56
  Workflow.__libraryAPIName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pagan-artifact",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Modern version control.",
5
5
  "main": "index.js",
6
6
  "bin": {
package/setup/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * art - Modern version control.
3
- * Module: Setup (v0.3.0)
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.${Date.now()}.${partIndex}.json`;
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
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * art - Modern version control.
3
- * Module: Utils (v0.3.0)
3
+ * Module: Utils (v0.3.1)
4
4
  */
5
5
 
6
6
  const fs = require('fs');
package/workflow/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * art - Modern version control.
3
- * Module: Workflow (v0.3.0)
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
- 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);
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
- if (!fs.existsSync(fullPath)) {
116
- throw new Error(`Path does not exist: ${targetPath}`);
117
- }
115
+ if (!fs.existsSync(fullPath)) {
116
+ throw new Error(`Path does not exist: ${targetPath}`);
117
+ }
118
118
 
119
- const artJson = JSON.parse(fs.readFileSync(artJsonPath, 'utf8'));
120
- const activeState = getStateByHash(artJson.active.branch, artJson.active.parent) || {};
121
- const currentStaged = getStagedChanges(artPath);
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
- const stats = fs.statSync(fullPath);
124
- const relativeTarget = path.relative(root, fullPath);
123
+ const stats = fs.statSync(fullPath);
124
+ const relativeTarget = path.relative(root, fullPath);
125
125
 
126
- if (!stats.isDirectory() && shouldIgnore(relativeTarget) && !activeState[relativeTarget]) {
127
- return `${relativeTarget} is being ignored.`;
128
- }
126
+ if (!stats.isDirectory() && shouldIgnore(relativeTarget) && !activeState[relativeTarget]) {
127
+ return `${relativeTarget} is being ignored.`;
128
+ }
129
129
 
130
- let filesToProcess = [];
130
+ let filesToProcess = [];
131
131
 
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);
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
- 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
- }
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
- if (filesToProcess.length === 0) return "No changes to add.";
145
+ if (filesToProcess.length === 0) return "No changes to add.";
146
146
 
147
- for (const relPath of filesToProcess) {
148
- const currentContent = fs.readFileSync(path.join(root, relPath), 'utf8');
149
- const previousContent = activeState[relPath];
147
+ for (const relPath of filesToProcess) {
148
+ const currentContent = fs.readFileSync(path.join(root, relPath), 'utf8');
149
+ const previousContent = activeState[relPath];
150
150
 
151
- if (previousContent === undefined) {
152
- currentStaged[relPath] = { type: 'createFile', content: currentContent };
153
- } else if (currentContent !== previousContent) {
154
- let start = 0;
151
+ if (previousContent === undefined) {
152
+ currentStaged[relPath] = { type: 'createFile', content: currentContent };
153
+ } else if (currentContent !== previousContent) {
154
+ let start = 0;
155
155
 
156
- while (start < previousContent.length && start < currentContent.length && previousContent[start] === currentContent[start]) {
157
- start++;
158
- }
156
+ while (start < previousContent.length && start < currentContent.length && previousContent[start] === currentContent[start]) {
157
+ start++;
158
+ }
159
159
 
160
- let oldEnd = previousContent.length - 1;
161
- let newEnd = currentContent.length - 1;
160
+ let oldEnd = previousContent.length - 1;
161
+ let newEnd = currentContent.length - 1;
162
162
 
163
- while (oldEnd >= start && newEnd >= start && previousContent[oldEnd] === currentContent[newEnd]) {
164
- oldEnd--; newEnd--;
165
- }
163
+ while (oldEnd >= start && newEnd >= start && previousContent[oldEnd] === currentContent[newEnd]) {
164
+ oldEnd--; newEnd--;
165
+ }
166
166
 
167
- const operations = [];
168
- const deletionLength = oldEnd - start + 1;
167
+ const operations = [];
168
+ const deletionLength = oldEnd - start + 1;
169
169
 
170
- if (deletionLength > 0) {
171
- operations.push({ type: 'delete', position: start, length: deletionLength });
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
- const insertionContent = currentContent.slice(start, newEnd + 1);
179
+ const insertionContent = currentContent.slice(start, newEnd + 1);
175
180
 
176
- if (insertionContent.length > 0) {
177
- operations.push({ type: 'insert', position: start, content: insertionContent });
178
- }
181
+ if (insertionContent.length > 0) {
182
+ operations.push({ type: 'insert', position: start, content: insertionContent });
183
+ }
179
184
 
180
- if (operations.length > 0) {
181
- currentStaged[relPath] = operations;
182
- }
183
- }
184
- }
185
+ if (operations.length > 0) {
186
+ currentStaged[relPath] = operations;
187
+ }
188
+ }
189
+ }
185
190
 
186
- if (fs.existsSync(stageDir)) fs.rmSync(stageDir, { recursive: true, force: true });
191
+ if (fs.existsSync(stageDir)) fs.rmSync(stageDir, { recursive: true, force: true });
187
192
 
188
- fs.mkdirSync(stageDir, { recursive: true });
193
+ fs.mkdirSync(stageDir, { recursive: true });
189
194
 
190
- const stageParts = [];
195
+ const stageParts = [];
191
196
 
192
- let currentPartChanges = {};
193
- let currentSize = 0;
197
+ let currentPartChanges = {};
198
+ let currentSize = 0;
194
199
 
195
- const savePart = () => {
196
- const partName = `part.${stageParts.length}.json`;
200
+ const savePart = () => {
201
+ const partName = `part.${stageParts.length}.json`;
197
202
 
198
- fs.writeFileSync(path.join(stageDir, partName), JSON.stringify({ changes: currentPartChanges }, null, 2));
199
- stageParts.push(partName);
200
- currentPartChanges = {};
201
- currentSize = 0;
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
- for (const [file, changes] of Object.entries(currentStaged)) {
205
- const size = JSON.stringify(changes).length;
209
+ for (const [file, changes] of Object.entries(currentStaged)) {
210
+ const size = JSON.stringify(changes).length;
206
211
 
207
- if (currentSize + size > MAX_PART_SIZE && Object.keys(currentPartChanges).length > 0) {
208
- savePart();
209
- }
212
+ if (currentSize + size > MAX_PART_SIZE && Object.keys(currentPartChanges).length > 0) {
213
+ savePart();
214
+ }
210
215
 
211
- currentPartChanges[file] = changes;
212
- currentSize += size;
213
- }
216
+ currentPartChanges[file] = changes;
217
+ currentSize += size;
218
+ }
214
219
 
215
- savePart();
220
+ savePart();
216
221
 
217
- fs.writeFileSync(path.join(stageDir, 'manifest.json'), JSON.stringify({ parts: stageParts }, null, 2));
222
+ fs.writeFileSync(path.join(stageDir, 'manifest.json'), JSON.stringify({ parts: stageParts }, null, 2));
218
223
 
219
- return `Added ${filesToProcess.length} file(s) to paginated stage.`;
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.0',
305
+ __libraryVersion: '0.3.1',
301
306
  __libraryAPIName: 'Workflow',
302
307
  status,
303
308
  add,