generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathjustfile
More file actions
152 lines (113 loc) · 4.08 KB
/
justfile
File metadata and controls
152 lines (113 loc) · 4.08 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
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 `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 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
[group('test')]
[doc('Run tests on all code')]
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`.
[private]
_new title type folder:
#!/usr/bin/env node
const fs = require('node:fs');
const path = require('node:path');
const today = new Date().toISOString().split('T')[0];
const title = "{{ title }}";
const fileTitle = "{{ kebabcase(title) }}";
console.info(`📝 Creating a new {{ type }} on ${today}`);
console.info(`🔍 Found {{ type }} title: ${title}`);
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);
};
console.info(`🔦 Checking for existing {{ type }}s in ${fullWritePath}`);
const resolvedPath = path.resolve(fullWritePath);
const template = fs.readFileSync(`${fullWritePath}/.template`)
const files = fs.readdirSync(resolvedPath)
.map(fileName => {
return path.join(fullWritePath, fileName);
})
.filter(isFile);
console.info(`🔍 Found ${(files.length + "").padStart(4, '0')} {{ type }}(s)`);
const nextNumber = files.length + 1;
const nextNumberString = (nextNumber + "").padStart(4, '0');
console.info(`🖊️ Setting your new {{ type }} to #${nextNumberString}`);
const nextFilePath = path.join(
resolvedPath,
`${nextNumberString}_${today}_${fileTitle}.md`
);
console.info(`📊 Attempting to save {{ type }} #${nextNumberString} to ${nextFilePath}`);
const content = eval(`\`${template}\``);
try {
fs.writeFileSync(nextFilePath, content);
console.log(`✅ Successfully created {{ type }} #${nextNumberString} for ${title} at ${nextFilePath}`);
} catch (e) {
console.error(`❌ ${e}`);
}