spec-up-t 1.1.15 → 1.1.17

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.
@@ -0,0 +1,67 @@
1
+ name: Create Spec-Up-T Project via Artifact
2
+
3
+ # Trigger the workflow manually with an input for the project name
4
+ on:
5
+ workflow_dispatch:
6
+ inputs:
7
+ project-name:
8
+ description: 'Name of the new project directory'
9
+ required: true
10
+ user-pat:
11
+ description: 'Your GitHub PAT (optional, to push to your own repo)'
12
+ required: false
13
+
14
+ jobs:
15
+ create-project:
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ # Step 1: Check out the spec-up-t repo
19
+ - name: Checkout spec-up-t repository
20
+ uses: actions/checkout@v4
21
+
22
+ # Step 2: Set up Node.js environment
23
+ - name: Set up Node.js
24
+ uses: actions/setup-node@v4
25
+ with:
26
+ node-version: '18' # Adjust to your required Node version
27
+
28
+ # Step 3: Install npx and the spec-up-t-starter-pack package
29
+ - name: Install dependencies and npx package
30
+ run: |
31
+ npm install -g create-spec-up-t
32
+
33
+ # Step 4: Run the npx command with the provided project name
34
+ - name: Create new project from boilerplate
35
+ run: |
36
+ npx create-spec-up-t ${{ github.event.inputs.project-name }}
37
+
38
+ # Step 5: List the generated project files (for verification)
39
+ - name: Verify generated project
40
+ run: |
41
+ ls -la ${{ github.event.inputs.project-name }}
42
+
43
+ # Step 6: Upload the generated project as an artifact
44
+ - name: Upload project as artifact
45
+ uses: actions/upload-artifact@v4
46
+ with:
47
+ name: ${{ github.event.inputs.project-name }}
48
+ path: ${{ github.event.inputs.project-name }}
49
+
50
+
51
+ - name: Push to new repository (if PAT provided)
52
+ if: github.event.inputs.user-pat != ''
53
+ env:
54
+ USER_PAT: ${{ github.event.inputs.user-pat }}
55
+ run: |
56
+ cd ${{ github.event.inputs.project-name }}
57
+ git init
58
+ git add .
59
+ git commit -m "Initial project's Spec-Up-T installation"
60
+ git remote add origin https://x-access-token:${{ env.USER_PAT }}@github.com/<username-from-user-or-dynamic>/${{ github.event.inputs.project-name }}.git
61
+ git push -u origin main
62
+ - name: Upload artifact (if no PAT)
63
+ if: github.event.inputs.user-pat == ''
64
+ uses: actions/upload-artifact@v4
65
+ with:
66
+ name: ${{ github.event.inputs.project-name }}
67
+ path: ${{ github.event.inputs.project-name }}
@@ -0,0 +1,140 @@
1
+ name: Create Spec-Up-T Project
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ project-name:
7
+ description: 'Name of the new project repository'
8
+ required: true
9
+ default: 'myproject'
10
+ username:
11
+ description: 'Your GitHub username (required if PAT is provided)'
12
+ required: false
13
+ user-pat:
14
+ description: 'Your GitHub PAT (optional, to push to your own repo)'
15
+ required: false
16
+
17
+ jobs:
18
+ create-project:
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - name: Checkout spec-up-t repository
22
+ uses: actions/checkout@v4
23
+
24
+ - name: Set up Node.js
25
+ uses: actions/setup-node@v4
26
+ with:
27
+ node-version: '18'
28
+
29
+ - name: Install create-spec-up-t
30
+ run: |
31
+ npm install -g create-spec-up-t
32
+
33
+ - name: Create new project from boilerplate
34
+ run: |
35
+ npx create-spec-up-t ${{ github.event.inputs.project-name }}
36
+
37
+ - name: Debug inputs and PAT
38
+ if: github.event.inputs.user-pat != ''
39
+ env:
40
+ USER_PAT: ${{ github.event.inputs.user-pat }}
41
+ run: |
42
+ echo "Username: ${{ github.event.inputs.username }}"
43
+ echo "Project Name: ${{ github.event.inputs.project-name }}"
44
+ curl -i -L -H "Authorization: token $USER_PAT" -H "Accept: application/vnd.github+json" https://api.github.com/user
45
+
46
+ - name: Create new repository
47
+ if: github.event.inputs.user-pat != ''
48
+ env:
49
+ USER_PAT: ${{ github.event.inputs.user-pat }}
50
+ run: |
51
+ curl -i -L \
52
+ -X POST \
53
+ -H "Authorization: token $USER_PAT" \
54
+ -H "Accept: application/vnd.github+json" \
55
+ https://api.github.com/user/repos \
56
+ -d '{"name":"${{ github.event.inputs.project-name }}","description":"Spec-Up-T project created via workflow","private":false}'
57
+
58
+ - name: Get repo public key
59
+ if: github.event.inputs.user-pat != ''
60
+ id: get-public-key
61
+ env:
62
+ USER_PAT: ${{ github.event.inputs.user-pat }}
63
+ run: |
64
+ RESPONSE=$(curl -L -H "Authorization: token $USER_PAT" -H "Accept: application/vnd.github+json" https://api.github.com/repos/${{ github.event.inputs.username }}/${{ github.event.inputs.project-name }}/actions/secrets/public-key)
65
+ echo "PUBLIC_KEY=$(echo $RESPONSE | jq -r .key)" >> $GITHUB_OUTPUT
66
+ echo "KEY_ID=$(echo $RESPONSE | jq -r .key_id)" >> $GITHUB_OUTPUT
67
+
68
+ # Install libsodium-wrappers locally
69
+ - name: Install libsodium-wrappers
70
+ if: github.event.inputs.user-pat != ''
71
+ run: |
72
+ npm install libsodium-wrappers
73
+
74
+ # Encrypt and set the PAT as a secret
75
+ - name: Set PAT as repo secret
76
+ if: github.event.inputs.user-pat != ''
77
+ env:
78
+ USER_PAT: ${{ github.event.inputs.user-pat }}
79
+ run: |
80
+ node -e "
81
+ const sodium = require('./node_modules/libsodium-wrappers');
82
+ (async () => {
83
+ await sodium.ready;
84
+ const publicKey = Buffer.from('${{ steps.get-public-key.outputs.PUBLIC_KEY }}', 'base64');
85
+ const secretValue = process.env.USER_PAT;
86
+ const messageBytes = Buffer.from(secretValue);
87
+ const encryptedBytes = sodium.crypto_box_seal(messageBytes, publicKey);
88
+ const encrypted = Buffer.from(encryptedBytes).toString('base64');
89
+ const keyId = '${{ steps.get-public-key.outputs.KEY_ID }}';
90
+
91
+ const response = await fetch('https://api.github.com/repos/${{ github.event.inputs.username }}/${{ github.event.inputs.project-name }}/actions/secrets/MY_PAT', {
92
+ method: 'PUT',
93
+ headers: {
94
+ 'Authorization': 'token ' + secretValue,
95
+ 'Accept': 'application/vnd.github+json'
96
+ },
97
+ body: JSON.stringify({
98
+ encrypted_value: encrypted,
99
+ key_id: keyId
100
+ })
101
+ });
102
+ if (response.ok) {
103
+ console.log('PAT stored as secret MY_PAT in the new repo');
104
+ } else {
105
+ console.error('Failed to set secret:', await response.text());
106
+ process.exit(1);
107
+ }
108
+ })();
109
+ "
110
+
111
+ - name: Configure Git identity
112
+ if: github.event.inputs.user-pat != ''
113
+ run: |
114
+ git config --global user.email "actions@github.com"
115
+ git config --global user.name "GitHub Actions"
116
+
117
+ - name: Push to new repository
118
+ if: github.event.inputs.user-pat != ''
119
+ env:
120
+ USER_PAT: ${{ github.event.inputs.user-pat }}
121
+ run: |
122
+ cd ${{ github.event.inputs.project-name }}
123
+ git init
124
+ git add .
125
+ git commit -m "Initial project's Spec-Up-T installation"
126
+ git branch -M main
127
+ git remote add origin https://x-access-token:${{ env.USER_PAT }}@github.com/${{ github.event.inputs.username }}/${{ github.event.inputs.project-name }}.git
128
+ git push -u origin main
129
+
130
+ - name: Output repository URL
131
+ if: github.event.inputs.user-pat != ''
132
+ run: |
133
+ echo "Your new Spec-Up-T project is at: https://github.com/${{ github.event.inputs.username }}/${{ github.event.inputs.project-name }}"
134
+
135
+ - name: Upload artifact (if no PAT)
136
+ if: github.event.inputs.user-pat == ''
137
+ uses: actions/upload-artifact@v4
138
+ with:
139
+ name: ${{ github.event.inputs.project-name }}
140
+ path: ${{ github.event.inputs.project-name }}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-up-t",
3
- "version": "1.1.15",
3
+ "version": "1.1.17",
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": {
@@ -31,7 +31,7 @@ function collectExternalReferences(options = {}) {
31
31
  `;
32
32
 
33
33
  const explanationNoExternalReferences =
34
- `\n❌ No external references were found in the specs.json file.
34
+ `❌ No external references were found in the specs.json file.
35
35
 
36
36
  There is no point in continuing without external references, so we stop here.
37
37
 
@@ -0,0 +1,119 @@
1
+ name: Menu
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ script:
7
+ description: 'Select the script to run'
8
+ type: choice
9
+ required: true
10
+ default: 'render'
11
+ options:
12
+ - edit
13
+ - render
14
+ - dev
15
+ - collectExternalReferencesCache
16
+ - collectExternalReferencesNoCache
17
+ - topdf
18
+ - freeze
19
+ - references
20
+ - help
21
+ - menu
22
+ - addremovexrefsource
23
+ - configure
24
+ - custom-update
25
+
26
+ jobs:
27
+ build-and-deploy-spec:
28
+ runs-on: ubuntu-latest
29
+ permissions:
30
+ contents: write
31
+ steps:
32
+ - name: Checkout 🛎️
33
+ uses: actions/checkout@v4
34
+ with:
35
+ persist-credentials: false
36
+
37
+ - name: Set up Node.js
38
+ uses: actions/setup-node@v4
39
+ with:
40
+ node-version: '18'
41
+
42
+ - name: Extract output_path from JSON
43
+ id: extract-output
44
+ run: |
45
+ OUTPUT_PATH=$(jq -r '.specs[0].output_path // "default/output"' specs.json)
46
+ if [ "$OUTPUT_PATH" = "null" ] || [ -z "$OUTPUT_PATH" ]; then
47
+ echo "Error: Unable to extract output_path from specs.json"
48
+ exit 1
49
+ fi
50
+ echo "OUTPUT_PATH=$OUTPUT_PATH" >> $GITHUB_ENV
51
+
52
+ - name: Install dependencies 🔧
53
+ run: |
54
+ echo "Installing dependencies..."
55
+ npm install
56
+ echo "Spec-Up-T version:"
57
+ npm list spec-up-t || echo "spec-up-t not found"
58
+
59
+ - name: Run selected script
60
+ env:
61
+ MY_PAT: ${{ secrets.MY_PAT }} # Make the secret available as an env var
62
+ run: |
63
+ case ${{ github.event.inputs.script }} in
64
+ "edit")
65
+ node -e "require('spec-up-t')()"
66
+ ;;
67
+ "render")
68
+ node --no-warnings -e "require('spec-up-t/index.js')({ nowatch: true })"
69
+ ;;
70
+ "dev")
71
+ node -e "require('spec-up-t')({ dev: true })"
72
+ ;;
73
+ "collectExternalReferencesCache")
74
+ node --no-warnings -e "require('spec-up-t/src/collect-external-references.js').collectExternalReferences({cache: true})"
75
+ ;;
76
+ "collectExternalReferencesNoCache")
77
+ node --no-warnings -e "require('spec-up-t/src/collect-external-references.js').collectExternalReferences({cache: false, pat: process.env.MY_PAT})"
78
+ ;;
79
+ "topdf")
80
+ node -e "require('spec-up-t/src/create-pdf.js')"
81
+ ;;
82
+ "freeze")
83
+ node -e "require('spec-up-t/src/freeze.js')"
84
+ ;;
85
+ "references")
86
+ node -e "require('spec-up-t/src/references.js')"
87
+ ;;
88
+ "help")
89
+ cat ./node_modules/spec-up-t/src/install-from-boilerplate/help.txt || echo "Help file not found"
90
+ ;;
91
+ "addremovexrefsource")
92
+ node --no-warnings -e "require('spec-up-t/src/add-remove-xref-source.js')"
93
+ ;;
94
+ "configure")
95
+ node --no-warnings -e "require('spec-up-t/src/configure.js')"
96
+ ;;
97
+ "custom-update")
98
+ npm update && node -e "require('spec-up-t/src/install-from-boilerplate/custom-update.js')"
99
+ ;;
100
+ *)
101
+ echo "Unknown script: ${{ github.event.inputs.script }}"
102
+ exit 1
103
+ ;;
104
+ esac
105
+
106
+ - name: Deploy to GitHub Pages
107
+ if: success() && github.event.inputs.script != 'help'
108
+ uses: peaceiris/actions-gh-pages@v3.7.3
109
+ with:
110
+ github_token: ${{ secrets.GITHUB_TOKEN }}
111
+ publish_dir: ${{ env.OUTPUT_PATH }}
112
+ allow_empty_commit: true
113
+ force_orphan: true
114
+
115
+ - name: Clean up
116
+ if: always() # Run even if previous steps fail
117
+ run: |
118
+ echo "Cleaning up..."
119
+ rm -rf node_modules