@madgex/fert 5.0.3 → 5.0.4

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/README.md CHANGED
@@ -198,7 +198,7 @@ Templates & CSS may be processed using the [CSS Modules](https://github.com/css-
198
198
  ## Publish
199
199
 
200
200
  From root, run for all services or a specific service:
201
- `fert publish --target=prod` | `fert publish --target=prod --service-name=jobseekers-frontend`
201
+ `fert publish --target=production` | `fert publish --target=production --service-name=jobseekers-frontend`
202
202
 
203
203
  Run for 1 service from the service folder:
204
204
  `cd services/jobseekers-frontend`
@@ -208,10 +208,10 @@ Run for 1 service from the service folder:
208
208
 
209
209
  `fert publish --target [target]`
210
210
 
211
- | Option | |
212
- | ----------- | ---------------------------------------------------------------------------- |
213
- | `--target` | Where to publish the `dist` directory assets.<br/>`dev` \| `prod` (`string`) |
214
- | `--dry-run` | Dry run, dont actually upload anything |
211
+ | Option | |
212
+ | ----------- | ---------------------------------------------------------------------------------- |
213
+ | `--target` | Where to publish the `dist` directory assets.<br/>`dev` \| `production` (`string`) |
214
+ | `--dry-run` | Dry run, dont actually upload anything |
215
215
 
216
216
  Send all files and directories created in the `dist` directory to either development or production versions of the Asset Store API. Files uploaded to the Asset Store API are available via a CloudFront-based CDN.
217
217
 
@@ -316,7 +316,19 @@ These options are available no matter the command used.
316
316
 
317
317
  # CI/CD
318
318
 
319
- It's intended that the branding repos have their own build/deploy pipeline. Each change that's merged to `master` will trigger a build (`npm run build` as a common entry point) and the resulting output directory (`dist`) is pushed up to the `asset-store-api` for use in production.
319
+ All branding repos use a common jekinsfile and Dockerfile to build/deploy, and will use this FERT tool.
320
+
321
+ - Here is the jenkinsfile all branding repos use: https://github.com/wiley/madgex-jenkins-shared-library/blob/master/vars/clientRepoDeploymentPipeline.groovy .
322
+ - And the Dockerfile they all use [is in this repo](shared/Dockerfile.brandingRepoPublish).
323
+
324
+ Each change that's pushed to a branch will trigger:
325
+
326
+ 1. a build (`npm run build` inside the [Dockerfile](shared/Dockerfile.brandingRepoPublish) as a common entry point), which creates a `dist` folder full of assets ready to upload.
327
+ 2. The [jenkinsfile](https://github.com/wiley/madgex-jenkins-shared-library/blob/master/vars/clientRepoDeploymentPipeline.groovy) pipeline will run `fert publish` to send all built assets to the Asset Store API.
328
+ 3. The [jenkinsfile](https://github.com/wiley/madgex-jenkins-shared-library/blob/master/vars/clientRepoDeploymentPipeline.groovy) pipeline will run `fert configs --publish`, Uploading the branding repo's client `/configs` to the configuration-api.
329
+
330
+ > [!NOTE]
331
+ > `master` branch will go to `production`. All other branches will go to `jb dev`.
320
332
 
321
333
  ## `npm scripts`
322
334
 
@@ -330,5 +342,3 @@ Here are the default npm scripts in a Fert-scaffolded project.
330
342
  }
331
343
  }
332
344
  ```
333
-
334
- Its expected that a Jenkins pipeline will run `fert publish` to send all built assets to the Asset Store API.
package/bin/cli.js CHANGED
@@ -37,7 +37,10 @@ const run = () => {
37
37
 
38
38
  cli
39
39
  .command('publish', 'Publish the project')
40
- .option('--target <env>', 'Environment to publish to, "dev" or "prod"')
40
+ .option(
41
+ '--target <env>',
42
+ 'Environment to publish to, "dev" or "production"'
43
+ )
41
44
  .option('--service-name <serviceName>', '[string] run a single service')
42
45
  .option('--dry-run', 'Dry run, dont actually upload anything')
43
46
  .action((...args) => serivceCommandBootstrap('publish', ...args));
@@ -3,10 +3,7 @@ const chalk = require('chalk');
3
3
  const {
4
4
  loadServiceConfigFiles,
5
5
  loadConfigFromFile,
6
- findFertConfigDir,
7
6
  } = require('../utils/index.js');
8
- const { getConfigAPI, validateLocalConfigs } = require('../utils/configs.js');
9
- const { handlePublish } = require('../commands/configs.js');
10
7
 
11
8
  const commandDevSever = require('./dev-server.js');
12
9
  const commandBuild = require('./build.js');
@@ -67,48 +64,18 @@ module.exports.serivceCommandBootstrap = async function serivceCommandBootstrap(
67
64
  console.log(
68
65
  `🔦 ${chalk.green('Running multi service mode')}, calling ${chalk.cyan(command)} on ${chalk.cyan(serviceConfigs.length)} ${serviceConfigs.length === 1 ? 'service' : 'services'} [${serviceConfigs.map((i) => chalk.cyanBright(i?.serviceConfig?.serviceName || 'Unknown')).join(', ')}]`
69
66
  );
70
- try {
71
- for (const { serviceConfig } of serviceConfigs) {
72
- try {
73
- await commandMap[command]({
74
- ...options,
75
- serviceName: serviceConfig.serviceName,
76
- });
77
- } catch (err) {
78
- throw new Error(
79
- `Failed to run command ${command} on service ${serviceConfig.serviceName}: ${err.message}`,
80
- { cause: err }
81
- );
82
- }
83
- }
84
67
 
85
- // if we're publishing, update all configs on configuration API
86
- if (command === 'publish') {
87
- options.target = options.target === 'dev' ? 'dev' : 'production';
88
- const rootDir = await findFertConfigDir();
89
- const { clientPropertyId } = await loadConfigFromFile({ dir: rootDir });
90
- const api = await getConfigAPI({
91
- clientPropertyId,
92
- environment: options.target,
68
+ for (const { serviceConfig } of serviceConfigs) {
69
+ try {
70
+ await commandMap[command]({
71
+ ...options,
72
+ serviceName: serviceConfig.serviceName,
93
73
  });
94
-
95
- // validate & upload local configs to configuration API
96
- if (!options.dryRun) {
97
- await handlePublish({ clientPropertyId, workingDir: rootDir }, api, {
98
- publish: options.target,
99
- });
100
- } else {
101
- await validateLocalConfigs({
102
- clientPropertyId,
103
- workingDir: rootDir,
104
- throwable: true,
105
- });
106
- }
107
-
108
- log.success(`${chalk.green('Publish completed successfully')}`);
74
+ } catch (err) {
75
+ throw new Error(
76
+ `Failed to run command ${command} on service ${serviceConfig.serviceName}: ${err.message}`,
77
+ { cause: err }
78
+ );
109
79
  }
110
- } catch (error) {
111
- log.error('Failed to run command', command, options);
112
- console.error(error);
113
80
  }
114
81
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@madgex/fert",
3
- "version": "5.0.3",
3
+ "version": "5.0.4",
4
4
  "description": "Tool to help build the V6 branding",
5
5
  "bin": {
6
6
  "fert": "./bin/cli.js"
@@ -1,93 +0,0 @@
1
- #!/usr/bin/env groovy
2
- library 'jenkins-shared-library'
3
-
4
- def productName = 'rollout-tool' // the name of the product to which this service belongs (jobboard/insights/employerbranding/core-services)
5
-
6
- def (subProductName, branchName) = "${env.JOB_NAME}".tokenize( '/' )
7
- def siteName = "$productName/$subProductName"
8
- def repositoryUri = "426517516965.dkr.ecr.eu-west-1.amazonaws.com"
9
-
10
- pipeline {
11
- agent {
12
- any {
13
- customWorkspace "workspace/${env.JOB_NAME}/${branchName}".replace('%2F', '-')
14
- }
15
- }
16
-
17
- options {
18
- timeout(time: 1, unit: 'HOURS')
19
- disableConcurrentBuilds()
20
- skipStagesAfterUnstable()
21
- skipDefaultCheckout()
22
- buildDiscarder(logRotator(daysToKeepStr: '10', numToKeepStr: '3'))
23
- }
24
-
25
- environment {
26
- NPM_TOKEN = credentials('MDS_NPM_TOKEN')
27
- AWS_CREDENTIALS_ID = "${params.ENVIRONMENTS == 'jb.dev' ? 'rollout-tool-consumer-key-parameter-store-jb-dev' : 'rollout-tool-consumer-key-parameter-store-production'}"
28
- }
29
-
30
- stages {
31
- stage('SCM') {
32
- steps {
33
- notifySlack('STARTED', 'fed-services-builds', 'jenkins-slack-token')
34
- checkout scm
35
- notifyBitbucketWithState('INPROGRESS')
36
- }
37
- }
38
-
39
- stage('Build') {
40
- steps {
41
- script {
42
- withCredentials([
43
- usernamePassword(credentialsId: 'github-lerna-write', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME'),
44
- [$class: 'AmazonWebServicesCredentialsBinding', credentialsId: "${env.AWS_CREDENTIALS_ID}"]
45
- ]){
46
-
47
- docker.build("madgex/front-end-rollout-tool", "--no-cache --build-arg NPM_TOKEN=$env.NPM_TOKEN --build-arg GIT_USERNAME=$GIT_USERNAME --build-arg GIT_PASSWORD=$GIT_PASSWORD .")
48
-
49
- sh """
50
- docker run --rm -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY madgex/front-end-rollout-tool:latest npm run publish -- --environment=${params.ENVIRONMENTS} --clientPropertyId=${params.CLIENT_PROPERTY_ID}
51
-
52
- """
53
- }
54
- }
55
- }
56
- }
57
- stage('Call branding service') {
58
- steps {
59
- script {
60
- build job: 'madgex-branding-service', parameters: [
61
- string(name: 'CLIENT_PROPERTY_ID', value: params.CLIENT_PROPERTY_ID),
62
- string(name: 'DESIGN_SYSTEM_VERSION', value: params.DESIGN_SYSTEM_VERSION),
63
- string(name: 'ENVIRONMENTS', value: params.ENVIRONMENTS),
64
- ]
65
- }
66
- }
67
- }
68
-
69
- }
70
-
71
- post {
72
- failure {
73
- script {
74
- notifyBitbucketWithState('FAILURE')
75
- // This channel is only for failures
76
- notifySlack(currentBuild.result, 'pipeline-alerts-fed', 'jenkins-slack-token')
77
- }
78
- }
79
- success {
80
- script {
81
- notifyBitbucketWithState('SUCCESS')
82
- }
83
- }
84
- always {
85
- script {
86
- // Necessary to get emailer to send out on success
87
- currentBuild.result = currentBuild.currentResult
88
- }
89
- notifySlack(currentBuild.result, 'fed-services-builds', 'jenkins-slack-token')
90
- cleanWs deleteDirs: true
91
- }
92
- }
93
- }