Skip to content

Commit f225b1d

Browse files
committed
Update the PDK scripts
1 parent 55d739b commit f225b1d

File tree

6 files changed

+849
-786
lines changed

6 files changed

+849
-786
lines changed

gulpfile.mjs

Lines changed: 76 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import minify from 'gulp-minify'
88

99
dotconfig.config()
1010

11-
// console.log(process.env)
12-
1311
/**
1412
* Different paths we use...
13+
* Don't modify this directly, use the environment variables
1514
*/
1615
const paths = {
1716
src: './src',
@@ -24,12 +23,66 @@ const paths = {
2423
acars: process.env.ACARS_SCRIPTS_PATH,
2524
}
2625

26+
/**
27+
* Build the project, copy the appropriate files over
28+
* @public
29+
*/
30+
export const build = series(buildTsTask, copyPackageTask)
31+
32+
/**
33+
* Build a distribution zip file, which can be easily uploaded
34+
* @public
35+
*/
36+
export const dist = series(
37+
build,
38+
buildZipTask,
39+
)
40+
41+
/**
42+
* Watch the files and distribute them to the
43+
* documents/vmsacars/data/<profile>/config directory
44+
* @public
45+
*/
46+
export const local = localTask
47+
48+
49+
/**
50+
* The default action
51+
* @default
52+
* @public
53+
*/
54+
export default build
55+
56+
57+
/**
58+
* The build steps that run from the csproj
59+
* Force the output path to go into our build directory
60+
* @internal
61+
*/
62+
export const csbuild = series(
63+
async () => {
64+
paths.acars = '../Content/config/default'
65+
},
66+
build,
67+
copyFilesToScriptsPathTask,
68+
)
69+
70+
/**
71+
*
72+
*
73+
*
74+
*/
75+
2776
/**
2877
* Configure the ts transpilation
2978
*/
3079
const tsProject = ts.createProject('tsconfig.json')
3180

32-
function build_ts() {
81+
/**
82+
* Build the Typescript files
83+
* @returns {module:stream.Stream.Transform | *}
84+
*/
85+
async function buildTsTask() {
3386
let pipeline = tsProject.src()
3487
.pipe(eslint())
3588
.pipe(eslint.failAfterError())
@@ -43,7 +96,8 @@ function build_ts() {
4396
mangle: false,
4497
}))*/
4598

46-
pipeline = pipeline.pipe(dest(paths.dist))
99+
pipeline = pipeline
100+
.pipe(dest(paths.dist))
47101

48102
return pipeline
49103
}
@@ -52,120 +106,65 @@ function build_ts() {
52106
*
53107
* @returns {*}
54108
*/
55-
function copy_package() {
109+
async function copyPackageTask() {
56110
return src([paths.src + '/package.json'])
57111
.pipe(dest(paths.dist))
58112
}
59113

60-
/**
61-
* Build the project, copy the appropriate files over
62-
*/
63-
export const build = series(build_ts, copy_package)
64-
65114
/**
66115
* Copy the files from dist into ACARS_SCRIPTS_PATH
67116
*
68117
*/
69-
export function copy() {
118+
export async function copyFilesToScriptsPathTask() {
70119
console.log(`Copying files to ${paths.acars}`)
71120

72-
return src(['./**/*', '!node_modules/**/*'], { 'cwd': paths.dist })
121+
return src(
122+
[
123+
'./**/*',
124+
'!node_modules/**/*',
125+
],
126+
{ 'cwd': paths.dist },
127+
)
73128
.pipe(dest(paths.acars))
74129
}
75130

76-
/**
77-
* The build steps that run from the csproj
78-
* Force the output path to go into our build directory
79-
*/
80-
export const csbuild = series(
81-
async () => {
82-
paths.acars = '../Content/config/default'
83-
},
84-
build,
85-
copy,
86-
)
87131

88132
/**
89133
* TODO: Build the distribution zip file
90134
*/
91-
function build_dist() {
135+
function buildZipTask() {
92136

93137
}
94138

95-
/**
96-
* Build a distribution zip file, which can be easily uploaded
97-
*/
98-
export const dist = series(
99-
build,
100-
build_dist,
101-
)
102139

103140
/**
104141
* Watch the src folder for updates, compile them and then copy them
105142
* to the config directory. ACARS should auto-reload
106143
*/
107-
export async function testing() {
144+
export async function testingTask() {
108145
watch('src/', {
109146
ignoreInitial: false,
110147
delay: 500,
111-
}, series(build, copy))
148+
}, series(build, copyFilesToScriptsPathTask))
112149
}
113150

114151
/**
115-
* Watch the files and distribute them out
152+
* Watch the files and then build and copy them to the documents directory
116153
*/
117-
export function watchFiles() {
118-
watch('src/', build)
154+
export async function localTask() {
155+
return watch('src/', { ignoreInitial: false }, series(build, copyFilesToScriptsPathTask), function() {
156+
cb()
157+
})
119158
}
120159

121-
export { watchFiles as watch }
122-
123160
/**
124161
* Clean up the /dest directory
125162
*/
126-
export async function clean() {
163+
export async function cleanTask() {
127164
try {
128165
await deleteAsync([paths.dist])
129166
await Promise.resolve()
130167
} catch (e) {
131168
console.log(e)
132169
}
133170
}
134-
135-
/**
136-
* The default action
137-
*/
138-
export default build
139-
140-
/**
141-
* Get the default profile name
142-
*
143-
* @returns {*}
144-
*/
145-
/*async function getDefaultProfilePath() {
146-
if (profileName === null || profileName === '') {
147-
const f = await fs.promises.readFile(`${paths.acars}/settings.json`)
148-
const settings = JSON.parse(f)
149-
profileName = settings.Profile
150-
console.log('No profile name set, looked in settings and used ' + profileName)
151-
}
152-
153-
// Read all of the profiles
154-
let dirent
155-
const dir = await fs.promises.opendir(`${paths.acars}/profiles`)
156-
for await (const dirent of dir) {
157-
const pf = await fs.promises.readFile(`${dirent.parentPath}/${dirent.name}`)
158-
if (pf === null) {
159-
continue
160-
}
161-
162-
const profile = JSON.parse(pf)
163-
console.log(profile)
164-
165-
if (profile.Name === profileName) {
166-
return `${paths.acars}/data/${profile.Domain}/config/`
167-
}
168-
}
169-
170-
return null
171-
}*/

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"lint": "eslint --fix",
1414
"format": "prettier --ignore-path .gitignore --write \"src/**/*.+(js|ts)\"",
1515
"testing": "gulp testing",
16-
"watch": "gulp watch"
16+
"local": "gulp local"
1717
},
1818
"keywords": [],
1919
"author": "Nabeel Shahzad <[email protected]>",
@@ -32,6 +32,7 @@
3232
"gulp-minify": "^3.1.0",
3333
"gulp-prettier": "^6.0.0",
3434
"gulp-typescript": "^6.0.0-alpha.1",
35+
"gulplog": "^2.2.0",
3536
"merge2": "^1.4.1",
3637
"prettier": "^3.3.3",
3738
"typescript": "^5.5.4"

src/defs.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export enum GateType {
1919
/** Added for MSFS */
2020
Gate_Extra = 15,
2121
/** Added for MSFS */
22-
Jetway = 16,
22+
Jetway = 16
2323
}
2424
/** The runway/taxiway surface */
2525
export enum Surface {
@@ -47,13 +47,13 @@ export enum Surface {
4747
Sand = 21,
4848
Shale = 22,
4949
Tarmac = 23,
50-
Unknown = 99999,
50+
Unknown = 99999
5151
}
5252
export enum AircraftType {
5353
Airliner = 0,
5454
Cargo = 1,
5555
GeneralAviation = 2,
56-
Helicopter = 3,
56+
Helicopter = 3
5757
}
5858
/** The type of engine */
5959
export enum EngineType {
@@ -62,7 +62,7 @@ export enum EngineType {
6262
None = 2,
6363
Helo = 3,
6464
Rocket = 4,
65-
Turboprop = 5,
65+
Turboprop = 5
6666
}
6767
export enum SimType {
6868
None = 0,
@@ -75,13 +75,13 @@ export enum SimType {
7575
/** Specifically only for MSFS 2020 */
7676
FlightSimulator2020 = 6,
7777
/** Specifically only for MSFS 2024 */
78-
FlightSimulator2024 = 7,
78+
FlightSimulator2024 = 7
7979
}
8080
export enum FareType {
8181
/** Primarily a passenger flight */
8282
Passenger = 0,
8383
/** Primarily a cargo flight */
84-
Cargo = 1,
84+
Cargo = 1
8585
}
8686
/** The different types of flight plans that can be parsed */
8787
export enum FlightPlanType {
@@ -94,7 +94,7 @@ export enum FlightPlanType {
9494
/** Flightplan was created using SimBrief */
9595
SimBrief = 3,
9696
/** Flightplan was create using Flight Simulator */
97-
MsFs = 4,
97+
MsFs = 4
9898
}
9999
/** The PIREP states - these match the phase */
100100
export enum PirepState {
@@ -131,7 +131,7 @@ export enum PirepState {
131131
/** The aircraft is on block at the gate */
132132
OnBlock = 15,
133133
/** The aircraft is climbing to its cruise altitude */
134-
InitialClimb = 16,
134+
InitialClimb = 16
135135
}
136136
/** The simtype for the rule file */
137137
export enum AircraftConfigSimType {
@@ -142,7 +142,7 @@ export enum AircraftConfigSimType {
142142
/** Configuration for MSFS 2020 *only* */
143143
MsFs20 = 3,
144144
/** Configuration for MSFS 2024 *only* */
145-
MsFs24 = 4,
145+
MsFs24 = 4
146146
}
147147
/** Features of an aircraft. They are binary on or off */
148148
export enum AircraftFeature {
@@ -166,7 +166,7 @@ export enum AircraftFeature {
166166
Transponder = 17,
167167
LandingGear = 18,
168168
Autopilot = 19,
169-
ExternalPower = 20,
169+
ExternalPower = 20
170170
}
171171
/** The type of the dataref */
172172
export enum FeatureType {
@@ -177,5 +177,5 @@ export enum FeatureType {
177177
/** An array of integers */
178178
IntArray = 3,
179179
/** An array of numbers */
180-
NumberArray = 4,
180+
NumberArray = 4
181181
}

0 commit comments

Comments
 (0)