spec-up-t 1.6.3 → 1.6.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-up-t",
3
- "version": "1.6.3",
3
+ "version": "1.6.5",
4
4
  "description": "Technical specification drafting tool that generates rich specification documents from markdown. Forked from https://github.com/decentralized-identity/spec-up by Daniel Buchner (https://github.com/csuwildcat)",
5
5
  "main": "./index",
6
6
  "repository": {
@@ -3,17 +3,20 @@ const { configOverwriteScriptsKeys } = require('./config-scripts-keys');
3
3
  const addScriptsKeys = require('./add-scripts-keys');
4
4
  const copySystemFiles = require('./copy-system-files');
5
5
  const { gitIgnoreEntries } = require('./config-gitignore-entries');
6
- const {updateGitignore} = require('./add-gitignore-entries');
6
+ const { updateGitignore } = require('./add-gitignore-entries');
7
+ const updateDependencies = require('./update-dependencies');
8
+ const Logger = require('../utils/logger');
7
9
 
8
10
 
9
11
  addScriptsKeys(configScriptsKeys, configOverwriteScriptsKeys);
10
12
  copySystemFiles();
11
13
  updateGitignore(gitIgnoreEntries.gitignorePath, gitIgnoreEntries.filesToAdd);
12
14
 
13
- const Logger = require('../utils/logger');
14
-
15
15
  // We can use this file to do any custom updates during post-install.
16
16
  const customUpdate = () => {
17
+ // Update dependencies based on package.spec-up-t.json
18
+ updateDependencies();
19
+
17
20
  // Custom logic here
18
21
  // ...
19
22
  }
@@ -0,0 +1,105 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const https = require('https');
4
+ const Logger = require('../utils/logger');
5
+
6
+ /**
7
+ * URL to the canonical package.spec-up-t.json in the starter-pack repository.
8
+ * This defines the recommended dependency versions for consuming repos.
9
+ */
10
+ const STARTER_PACK_PACKAGE_URL = 'https://raw.githubusercontent.com/trustoverip/spec-up-t-starter-pack/main/package.spec-up-t.json';
11
+
12
+ /**
13
+ * Fetches package.spec-up-t.json from the remote starter-pack repository.
14
+ *
15
+ * @returns {Promise<Object>} The parsed package.spec-up-t.json content
16
+ * @throws {Error} If the fetch fails or the response is invalid
17
+ */
18
+ function fetchStarterPackageConfig() {
19
+ return new Promise((resolve, reject) => {
20
+ https.get(STARTER_PACK_PACKAGE_URL, (response) => {
21
+ if (response.statusCode !== 200) {
22
+ reject(new Error(`Failed to fetch package.spec-up-t.json: HTTP ${response.statusCode}`));
23
+ return;
24
+ }
25
+
26
+ let data = '';
27
+ response.on('data', (chunk) => {
28
+ data += chunk;
29
+ });
30
+
31
+ response.on('end', () => {
32
+ try {
33
+ const config = JSON.parse(data);
34
+ resolve(config);
35
+ } catch (error) {
36
+ reject(new Error(`Failed to parse package.spec-up-t.json: ${error.message}`));
37
+ }
38
+ });
39
+ }).on('error', (error) => {
40
+ reject(new Error(`Network error fetching package.spec-up-t.json: ${error.message}`));
41
+ });
42
+ });
43
+ }
44
+
45
+ /**
46
+ * Updates dependencies in the consuming repo's package.json based on the
47
+ * canonical package.spec-up-t.json from the starter-pack repository.
48
+ * This ensures that the consuming repo always has the correct dependency versions
49
+ * as specified by the spec-up-t-starter-pack.
50
+ */
51
+ async function updateDependencies() {
52
+ // Path to the consuming repo's package.json
53
+ const consumerPackagePath = path.resolve(process.cwd(), 'package.json');
54
+
55
+ try {
56
+ // Fetch the canonical package.spec-up-t.json from the starter-pack repo
57
+ Logger.info('Fetching latest dependency configuration...');
58
+ const specUpPackage = await fetchStarterPackageConfig();
59
+
60
+ // Read consuming repo's package.json
61
+ if (!fs.existsSync(consumerPackagePath)) {
62
+ Logger.error('package.json not found at:', consumerPackagePath);
63
+ return;
64
+ }
65
+
66
+ const consumerPackageData = fs.readFileSync(consumerPackagePath, 'utf8');
67
+ const consumerPackage = JSON.parse(consumerPackageData);
68
+
69
+ // Initialize dependencies section if it doesn't exist
70
+ if (!consumerPackage.dependencies) {
71
+ consumerPackage.dependencies = {};
72
+ }
73
+
74
+ // Check if there are dependencies to update
75
+ if (!specUpPackage.dependencies) {
76
+ Logger.info('No dependencies found in package.spec-up-t.json');
77
+ return;
78
+ }
79
+
80
+ let updatedCount = 0;
81
+
82
+ // Update each dependency from package.spec-up-t.json
83
+ for (const [packageName, version] of Object.entries(specUpPackage.dependencies)) {
84
+ const currentVersion = consumerPackage.dependencies[packageName];
85
+
86
+ if (currentVersion !== version) {
87
+ consumerPackage.dependencies[packageName] = version;
88
+ updatedCount++;
89
+ Logger.info(`Updated ${packageName}: ${currentVersion || 'not installed'} -> ${version}`);
90
+ }
91
+ }
92
+
93
+ if (updatedCount > 0) {
94
+ // Write the updated package.json back to disk
95
+ fs.writeFileSync(consumerPackagePath, JSON.stringify(consumerPackage, null, 2) + '\n', 'utf8');
96
+ Logger.success(`Successfully updated ${updatedCount} dependenc${updatedCount === 1 ? 'y' : 'ies'} in package.json`);
97
+ } else {
98
+ Logger.info('All dependencies are already up to date');
99
+ }
100
+ } catch (error) {
101
+ Logger.error('Error updating dependencies:', error.message);
102
+ }
103
+ }
104
+
105
+ module.exports = updateDependencies;
@@ -19,6 +19,9 @@ const defaultQuestions = [
19
19
  { field: 'title', prompt: 'Enter title', defaultValue: 'Spec-Up-T Starterpack' },
20
20
  { field: 'description', prompt: 'Enter description', defaultValue: 'Create technical specifications in markdown. Based on the original Spec-Up, extended with Terminology tooling' },
21
21
  { field: 'author', prompt: 'Enter author', defaultValue: 'Trust over IP Foundation' },
22
+ { field: 'logo', prompt: 'Enter logo URL', defaultValue: 'https://raw.githubusercontent.com/trustoverip/spec-up-t/refs/heads/master/src/install-from-boilerplate/boilerplate/static/logo.svg' },
23
+ { field: 'logo_link', prompt: 'Enter logo link URL', defaultValue: 'https://github.com/trustoverip/spec-up-t' },
24
+ { field: 'favicon', prompt: 'Enter favicon URL', defaultValue: 'https://raw.githubusercontent.com/trustoverip/spec-up-t/refs/heads/master/src/install-from-boilerplate/boilerplate/static/favicon.ico' },
22
25
  { field: 'account', prompt: 'Enter account', defaultValue: 'trustoverip' },
23
26
  { field: 'repo', prompt: 'Enter repo', defaultValue: 'spec-up-t-starter-pack' }
24
27
  ];
@@ -11,6 +11,11 @@
11
11
  const { execSync } = require('child_process');
12
12
  const Logger = require('./logger');
13
13
 
14
+ // Fixed PATH for security: only system directories, not user-writable
15
+ const FIXED_PATH = process.platform === 'win32'
16
+ ? 'C:\\Windows\\system32;C:\\Windows'
17
+ : '/usr/bin:/bin:/usr/sbin:/sbin';
18
+
14
19
  /**
15
20
  * Gets the current Git branch name
16
21
  *
@@ -21,7 +26,8 @@ function getCurrentBranch() {
21
26
  const branch = execSync('git branch --show-current', {
22
27
  encoding: 'utf8',
23
28
  timeout: 5000,
24
- stdio: ['pipe', 'pipe', 'pipe']
29
+ stdio: ['pipe', 'pipe', 'pipe'],
30
+ env: { ...process.env, PATH: FIXED_PATH }
25
31
  }).trim();
26
32
 
27
33
  if (branch) {
@@ -33,7 +39,8 @@ function getCurrentBranch() {
33
39
  const head = execSync('git rev-parse --abbrev-ref HEAD', {
34
40
  encoding: 'utf8',
35
41
  timeout: 5000,
36
- stdio: ['pipe', 'pipe', 'pipe']
42
+ stdio: ['pipe', 'pipe', 'pipe'],
43
+ env: { ...process.env, PATH: FIXED_PATH }
37
44
  }).trim();
38
45
 
39
46
  if (head && head !== 'HEAD') {