-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathjustfile
More file actions
178 lines (137 loc) · 4.99 KB
/
justfile
File metadata and controls
178 lines (137 loc) · 4.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
alias h := _default
alias help := _default
@_default:
just --list --list-submodules
[group('alias')]
[doc('Alias for `client`')]
mod c './.justscripts/just/client.just'
[group('alias')]
[doc('Alias for `database`')]
mod db './.justscripts/just/database.just'
[group('alias')]
[doc('Alias for `risk-assessments`')]
mod cve './.justscripts/just/risk-assessments.just'
[group('alias')]
[doc('Alias for `decisions`')]
mod rfc './.justscripts/just/decisions.just'
[group('alias')]
[doc('Alias for `migrate`')]
mod m './.justscripts/just/migrate.just'
[group('alias')]
[doc('Alias for `server`')]
mod s './.justscripts/just/server.just'
[group('alias')]
[doc('Alias for `cloud`')]
mod cd './.justscripts/just/cloud.just'
[group('alias')]
[doc('Alias for `dev`')]
mod d './.justscripts/just/dev.just'
[group('alias')]
[doc('Alias for `structurizr`')]
mod s9r './.justscripts/just/structurizr.just'
[group('sub-command')]
[doc('Run commands against `client/` code')]
mod client './.justscripts/just/client.just'
[group('sub-command')]
[doc('Run dev-related docker compose commands')]
mod dev './.justscripts/just/dev.just'
[group('sub-command')]
[doc('Run database commands against `refiner/` code')]
mod database './.justscripts/just/database.just'
[group('sub-command')]
[doc('Run migration commands')]
mod migrate './.justscripts/just/migrate.just'
[group('sub-command')]
[doc('Run server commands against `refiner/` code')]
mod server './.justscripts/just/server.just'
[group('sub-command')]
[doc('Run commands against Azure')]
mod cloud './.justscripts/just/cloud.just'
[group('sub-command')]
[doc('Run Structurizr commands')]
mod structurizr './.justscripts/just/structurizr.just'
[group('sub-command')]
[doc('Run risk assessments commands')]
mod risk-assessments './.justscripts/just/risk-assessments.just'
[group('sub-command')]
[doc('Run decision records commands')]
mod decisions './.justscripts/just/decisions.just'
alias l := lint
alias t := test
[doc('Run linting and formatting rules on all code')]
lint:
just client::run lint fmt
just server::lint
[doc('Run tests on all code')]
[group('test')]
test:
just server::test
just client::run test:coverage
just client::run e2e
# NOTE: The recipe below named `_new` is **only** called from other Justfiles
# that create files from .template files found next to them. Currently it's
# used for managing and authoring `docs/decisions` and `docs/risk-assessments`
[private]
_new title type folder:
#!/usr/bin/env node
const fs = require('node:fs');
const path = require('node:path');
const os = require('os');
const today = new Date().toISOString().split('T')[0];
const title = "{{ title }}";
const fileTitle = "{{ kebabcase(title) }}";
const isCve = "{{ type }}" === "risk assessment"
console.info(`📝 Creating a new {{ type }} on ${today}`);
console.info(`🔍 Found {{ type }} title: ${title}`);
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'new-'));
const runningFromDir = path.join("{{ replace(justfile_directory(), '\', '/') }}");
const folderPath = '{{ folder }}';
let fullWritePath;
if (runningFromDir.endsWith(folderPath)) {
fullWritePath = runningFromDir;
} else {
fullWritePath = path.join(runningFromDir, folderPath);
}
const isFile = fileName => {
const re = /[0-9]{4}/g;
return fs.lstatSync(fileName).isFile() && fileName.match(re);
};
let resolvedPath = ''
let nextNumberString = ''
let nextNumber = ''
if (isCve) {
console.info(`🕵️ This is a {{ type }} and will be saved to a temporary directory`)
} else {
console.info(`🔦 Checking for existing {{ type }}s in ${fullWritePath}`);
resolvedPath = path.resolve(fullWritePath);
const files = fs.readdirSync(resolvedPath)
.map(fileName => {
return path.join(fullWritePath, fileName);
})
.filter(isFile);
console.info(`🔍 Found ${(files.length + "").padStart(4, '0')} {{ type }}(s)`);
nextNumber = files.length + 1;
nextNumberString = (nextNumber + "").padStart(4, '0');
console.info(`🖊️ Setting your new {{ type }} to #${nextNumberString}`);
}
const nextFilePath = path.join(
(isCve ? tmpDir : resolvedPath),
(isCve ? `${today}_${fileTitle}.md` : `${nextNumberString}_${today}_${fileTitle}.md`)
);
if (isCve) {
console.info(`📊 Attempting to save {{ type }} to ${nextFilePath}`)
} else {
console.info(`📊 Attempting to save {{ type }} #${nextNumberString} to ${nextFilePath}`);
}
const template = fs.readFileSync(`${fullWritePath}/.template`)
const content = eval(`\`${template}\``);
try {
fs.writeFileSync(nextFilePath, content);
if (isCve) {
console.log(`✅ Successfully created {{ type }} for ${title} at ${nextFilePath}`);
} else {
console.log(`✅ Successfully created {{ type }} #${nextNumberString} for ${title} at ${nextFilePath}`);
}
} catch (e) {
console.error(`❌ ${e}`);
}