web-documentation 1.0.40 → 1.0.41

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": "web-documentation",
3
- "version": "1.0.40",
3
+ "version": "1.0.41",
4
4
  "description": "Declarative multilanguage documentation website generator",
5
5
  "keywords": [
6
6
  "documentation",
package/source/deploy.ts CHANGED
@@ -50,14 +50,13 @@ export interface WebDocumentationConfiguration {
50
50
  tagline?: string
51
51
  trackingCode?: string
52
52
  }
53
-
54
- interface MAKE_TEMPORARY_FILE_OPTIONS {
53
+ interface MakeTemporaryFileOptions {
55
54
  directory: boolean
56
55
  encoding?: BufferEncoding | null
57
56
  extension: string
58
57
  prefix: string
59
58
  }
60
- interface SCOPE_TYPE extends Mapping<unknown> {
59
+ interface PackageConfiguration extends Mapping<unknown> {
61
60
  description?: string
62
61
  webDocumentation?: WebDocumentationConfiguration
63
62
  files?: Array<string>
@@ -105,7 +104,8 @@ const DOCUMENTATION_WEBSITE_REPOSITORY =
105
104
  // `git@github.com:thaibault/${DOCUMENTATION_WEBSITE_NAME}`
106
105
  `https://github.com/thaibault/${DOCUMENTATION_WEBSITE_NAME}.git`
107
106
  const PROJECT_PAGE_COMMIT_MESSAGE = 'Update project homepage content.'
108
- let SCOPE: SCOPE_TYPE = {name: '__dummy__', version: '1.0.0'}
107
+ let PACKAGE_CONFIGURATION: PackageConfiguration =
108
+ {name: '__dummy__', version: '1.0.0'}
109
109
  let HAS_API_DOCUMENTATION = false
110
110
  // endregion
111
111
  // region functions
@@ -116,9 +116,9 @@ let HAS_API_DOCUMENTATION = false
116
116
  * @returns Determined file path.
117
117
  */
118
118
  const makeTemporaryFile = async (
119
- givenOptions: Partial<MAKE_TEMPORARY_FILE_OPTIONS> = {}
119
+ givenOptions: Partial<MakeTemporaryFileOptions> = {}
120
120
  ): Promise<string> => {
121
- const options: MAKE_TEMPORARY_FILE_OPTIONS = {
121
+ const options: MakeTemporaryFileOptions = {
122
122
  directory: false,
123
123
  encoding: 'utf8',
124
124
  extension: '',
@@ -243,13 +243,13 @@ const generateAndPushNewDocumentationPage = async (
243
243
 
244
244
  let parameters: Mapping<unknown> = {}
245
245
  for (const [key, value] of Object.entries(
246
- SCOPE.webDocumentation || {}
246
+ PACKAGE_CONFIGURATION.webDocumentation || {}
247
247
  ))
248
248
  parameters[camelCaseToDelimited(key).toUpperCase()] = value
249
- if (!parameters.TAGLINE && SCOPE.description)
250
- parameters.TAGLINE = SCOPE.description
251
- if (!parameters.NAME && SCOPE.name)
252
- parameters.NAME = SCOPE.name
249
+ if (!parameters.TAGLINE && PACKAGE_CONFIGURATION.description)
250
+ parameters.TAGLINE = PACKAGE_CONFIGURATION.description
251
+ if (!parameters.NAME && PACKAGE_CONFIGURATION.name)
252
+ parameters.NAME = PACKAGE_CONFIGURATION.name
253
253
 
254
254
  log.debug(`Found parameters "${represent(parameters)}" to render.`)
255
255
 
@@ -278,7 +278,8 @@ const generateAndPushNewDocumentationPage = async (
278
278
 
279
279
  const serializedParameters: string =
280
280
  JSON.stringify(evaluateDynamicData(
281
- BUILD_DOCUMENTATION_PAGE_CONFIGURATION, {parameters, ...SCOPE}
281
+ BUILD_DOCUMENTATION_PAGE_CONFIGURATION,
282
+ {parameters, ...PACKAGE_CONFIGURATION}
282
283
  ))
283
284
  const parametersFilePath: string =
284
285
  await makeTemporaryFile({extension: '.json'})
@@ -286,7 +287,7 @@ const generateAndPushNewDocumentationPage = async (
286
287
 
287
288
  const evaluationResult: EvaluationResult = evaluate(
288
289
  BUILD_DOCUMENTATION_PAGE_COMMAND_TEMPLATE,
289
- {parameters, parametersFilePath, ...SCOPE}
290
+ {parameters, parametersFilePath, ...PACKAGE_CONFIGURATION}
290
291
  )
291
292
 
292
293
  if (evaluationResult.error)
@@ -343,8 +344,8 @@ const generateAndPushNewDocumentationPage = async (
343
344
  * @returns Path to build distribution bundle or "null" of building failed.
344
345
  */
345
346
  const createDistributionBundle = async (): Promise<null | string> => {
346
- if (SCOPE.scripts && SCOPE.scripts.build) {
347
- const buildCommand = `yarn ${SCOPE.scripts.build}`
347
+ if (PACKAGE_CONFIGURATION.scripts?.build) {
348
+ const buildCommand = `yarn ${PACKAGE_CONFIGURATION.scripts.build}`
348
349
  log.info(`Build distribution bundle via "${buildCommand}".`)
349
350
  log.debug(run(buildCommand))
350
351
  }
@@ -353,9 +354,9 @@ const createDistributionBundle = async (): Promise<null | string> => {
353
354
  const distributionBundleFilePath: string =
354
355
  await makeTemporaryFile({extension: '.zip'})
355
356
 
356
- const filePaths = SCOPE.files || []
357
- if (SCOPE.main)
358
- filePaths.push(SCOPE.main)
357
+ const filePaths = PACKAGE_CONFIGURATION.files || []
358
+ if (PACKAGE_CONFIGURATION.main)
359
+ filePaths.push(PACKAGE_CONFIGURATION.main)
359
360
 
360
361
  if (filePaths.length === 0)
361
362
  return null
@@ -527,10 +528,12 @@ const main = async (): Promise<void> => {
527
528
  run('git branch').includes('* main') &&
528
529
  run('git branch --all').includes('gh-pages')
529
530
  ) {
530
- SCOPE = optionalRequire(resolve('./package.json')) || SCOPE
531
+ PACKAGE_CONFIGURATION =
532
+ optionalRequire(resolve('./package.json')) ||
533
+ PACKAGE_CONFIGURATION
531
534
 
532
535
  const evaluationResult: EvaluationResult = evaluate(
533
- `\`${API_DOCUMENTATION_PATH_SUFFIX}\``, SCOPE
536
+ `\`${API_DOCUMENTATION_PATH_SUFFIX}\``, PACKAGE_CONFIGURATION
534
537
  )
535
538
 
536
539
  if (evaluationResult.error)
@@ -568,8 +571,10 @@ const main = async (): Promise<void> => {
568
571
  }
569
572
 
570
573
  HAS_API_DOCUMENTATION =
571
- Boolean(SCOPE.scripts) &&
572
- Object.prototype.hasOwnProperty.call(SCOPE.scripts, 'document')
574
+ Boolean(PACKAGE_CONFIGURATION.scripts) &&
575
+ Object.prototype.hasOwnProperty.call(
576
+ PACKAGE_CONFIGURATION.scripts, 'document'
577
+ )
573
578
  if (HAS_API_DOCUMENTATION) {
574
579
  log.info('API documentation creation script detected.')
575
580
  try {
@@ -710,8 +715,10 @@ const main = async (): Promise<void> => {
710
715
  /* eslint-disable @typescript-eslint/no-unnecessary-condition */
711
716
  RUN_FINAL_BUILD &&
712
717
  /* eslint-enable @typescript-eslint/no-unnecessary-condition */
713
- Boolean(SCOPE.scripts) &&
714
- Object.prototype.hasOwnProperty.call(SCOPE.scripts, 'build')
718
+ Boolean(PACKAGE_CONFIGURATION.scripts) &&
719
+ Object.prototype.hasOwnProperty.call(
720
+ PACKAGE_CONFIGURATION.scripts, 'build'
721
+ )
715
722
  )
716
723
  // Prepare build artifacts for further local usage.
717
724
  log.debug(run('yarn build'))