@payfit/nx-core 4.10.0-ephemeral.0 → 4.10.0
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 +2 -1
- package/dist/src/executors/publisher/docker.d.ts +5 -0
- package/dist/src/executors/publisher/docker.js +21 -0
- package/dist/src/executors/publisher/docker.js.map +1 -0
- package/dist/src/executors/publisher/executor.d.ts +4 -0
- package/dist/src/executors/publisher/executor.js +23 -0
- package/dist/src/executors/publisher/executor.js.map +1 -0
- package/dist/src/executors/publisher/helm.d.ts +7 -0
- package/dist/src/executors/publisher/helm.js +40 -0
- package/dist/src/executors/publisher/helm.js.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +62 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/scripts/version-actions.d.ts +25 -0
- package/dist/src/scripts/version-actions.js +59 -0
- package/dist/src/scripts/version-actions.js.map +1 -0
- package/dist/src/utils/aws-auth.d.ts +39 -0
- package/dist/src/utils/aws-auth.js +84 -0
- package/dist/src/utils/aws-auth.js.map +1 -0
- package/{src/utils/docker.ts → dist/src/utils/docker.d.ts} +6 -22
- package/dist/src/utils/docker.js +33 -0
- package/dist/src/utils/docker.js.map +1 -0
- package/dist/src/utils/exec.d.ts +7 -0
- package/dist/src/utils/exec.js +25 -0
- package/dist/src/utils/exec.js.map +1 -0
- package/dist/src/utils/get-version.d.ts +6 -0
- package/dist/src/utils/get-version.js +14 -0
- package/dist/src/utils/get-version.js.map +1 -0
- package/dist/src/utils/github.d.ts +4 -0
- package/dist/src/utils/github.js +17 -0
- package/dist/src/utils/github.js.map +1 -0
- package/dist/src/utils/helm.d.ts +48 -0
- package/dist/src/utils/helm.js +91 -0
- package/dist/src/utils/helm.js.map +1 -0
- package/dist/src/utils/import-esm.d.ts +2 -0
- package/dist/src/utils/import-esm.js +12 -0
- package/dist/src/utils/import-esm.js.map +1 -0
- package/dist/src/utils/tsh.d.ts +10 -0
- package/dist/src/utils/tsh.js +107 -0
- package/dist/src/utils/tsh.js.map +1 -0
- package/package.json +24 -7
- package/.env.test +0 -0
- package/eslint.config.mjs +0 -31
- package/project.json +0 -43
- package/src/executors/publisher/docker.ts +0 -34
- package/src/executors/publisher/executor.ts +0 -30
- package/src/executors/publisher/helm.ts +0 -55
- package/src/index.ts +0 -77
- package/src/scripts/version-action.ts +0 -89
- package/src/utils/aws-auth.ts +0 -100
- package/src/utils/exec.spec.ts +0 -16
- package/src/utils/exec.ts +0 -31
- package/src/utils/get-version.ts +0 -11
- package/src/utils/github.ts +0 -14
- package/src/utils/helm.ts +0 -125
- package/src/utils/import-esm.ts +0 -10
- package/src/utils/tsh.ts +0 -127
- package/tsconfig.json +0 -19
- package/tsconfig.lib.json +0 -22
- package/tsconfig.spec.json +0 -28
- package/vite.config.ts +0 -28
- /package/{src → dist/src}/executors/publisher/schema.d.ts +0 -0
- /package/{src → dist/src}/executors/publisher/schema.json +0 -0
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { ProjectGraph, Tree } from '@nx/devkit'
|
|
2
|
-
import { VersionActions } from 'nx/release'
|
|
3
|
-
import { NxReleaseVersionConfiguration } from 'nx/src/config/nx-json'
|
|
4
|
-
import { inc } from 'semver'
|
|
5
|
-
|
|
6
|
-
export default class customVersionAction extends VersionActions {
|
|
7
|
-
validManifestFilenames: string[]
|
|
8
|
-
async readCurrentVersionFromSourceManifest(
|
|
9
|
-
tree: Tree,
|
|
10
|
-
): Promise<{ currentVersion: string; manifestPath: string } | null> {
|
|
11
|
-
return {
|
|
12
|
-
currentVersion: '0.0.0',
|
|
13
|
-
manifestPath: 'apps/my-nest-app/project.json',
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
async readCurrentVersionFromRegistry(
|
|
17
|
-
tree: Tree,
|
|
18
|
-
currentVersionResolverMetadata: NxReleaseVersionConfiguration['currentVersionResolverMetadata'],
|
|
19
|
-
): Promise<{ currentVersion: string | null; logText: string } | null> {
|
|
20
|
-
return {
|
|
21
|
-
currentVersion: '0.0.0',
|
|
22
|
-
logText: 'Current version from registry',
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
async readCurrentVersionOfDependency(
|
|
26
|
-
tree: Tree,
|
|
27
|
-
projectGraph: ProjectGraph,
|
|
28
|
-
dependencyProjectName: string,
|
|
29
|
-
): Promise<{
|
|
30
|
-
currentVersion: string | null
|
|
31
|
-
dependencyCollection: string | null
|
|
32
|
-
}> {
|
|
33
|
-
return {
|
|
34
|
-
currentVersion: '0.0.0',
|
|
35
|
-
dependencyCollection: '0.0.0',
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
async isLocalDependencyProtocol(versionSpecifier: string): Promise<boolean> {
|
|
39
|
-
return false
|
|
40
|
-
}
|
|
41
|
-
async updateProjectVersion(
|
|
42
|
-
tree: Tree,
|
|
43
|
-
newVersion: string,
|
|
44
|
-
): Promise<string[]> {
|
|
45
|
-
// Update the version in the VERSION file
|
|
46
|
-
const currentProject = this.projectGraphNode.name
|
|
47
|
-
const versionFilePath = `dist/apps/${currentProject}/VERSION`
|
|
48
|
-
tree.write(versionFilePath, newVersion)
|
|
49
|
-
return []
|
|
50
|
-
}
|
|
51
|
-
async updateProjectDependencies(
|
|
52
|
-
tree: Tree,
|
|
53
|
-
projectGraph: ProjectGraph,
|
|
54
|
-
dependenciesToUpdate: Record<string, string>,
|
|
55
|
-
): Promise<string[]> {
|
|
56
|
-
return []
|
|
57
|
-
}
|
|
58
|
-
async calculateNewVersion(
|
|
59
|
-
currentVersion: string | null,
|
|
60
|
-
newVersionInput: string,
|
|
61
|
-
newVersionInputReason: string,
|
|
62
|
-
newVersionInputReasonData: Record<string, unknown>,
|
|
63
|
-
preid: string,
|
|
64
|
-
): Promise<{
|
|
65
|
-
newVersion: string
|
|
66
|
-
logText: string
|
|
67
|
-
}> {
|
|
68
|
-
function formatDate() {
|
|
69
|
-
const date = new Date()
|
|
70
|
-
const year = date.getFullYear()
|
|
71
|
-
const month = String(date.getMonth() + 1).padStart(2, '0') // getMonth() returns 0-11
|
|
72
|
-
const day = date.getDate()
|
|
73
|
-
|
|
74
|
-
return `${year}${month}.${day}.`
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function getNewVersionFromCurrentVersion(currentVersion: string) {
|
|
78
|
-
const expectedPattern = formatDate()
|
|
79
|
-
return !currentVersion.startsWith(expectedPattern)
|
|
80
|
-
? `${expectedPattern}0`
|
|
81
|
-
: inc(currentVersion, 'patch')
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
newVersion: getNewVersionFromCurrentVersion(currentVersion),
|
|
86
|
-
logText: `New version: ${getNewVersionFromCurrentVersion(currentVersion)}`,
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
package/src/utils/aws-auth.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { getDockerOrPodman } from './docker'
|
|
2
|
-
import { exec_command } from './exec'
|
|
3
|
-
|
|
4
|
-
let profileName = 'OIDC-PROFILE'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Return the AWS profile name to use in AWS cli commands
|
|
8
|
-
*/
|
|
9
|
-
export function getProfileName() {
|
|
10
|
-
return profileName
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Retrieves the AWS credentials from environment variables.
|
|
15
|
-
* Ensures that `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_DEFAULT_REGION` are properly set.
|
|
16
|
-
* Throws an error if credentials or region are missing.
|
|
17
|
-
*
|
|
18
|
-
* @return {Object} An object containing AWS credentials.
|
|
19
|
-
* @return {string} return.accessKeyId The AWS Access Key ID.
|
|
20
|
-
* @return {string} return.secretAccessKey The AWS Secret Access Key.
|
|
21
|
-
* @return {string} return.region The AWS Region.
|
|
22
|
-
*/
|
|
23
|
-
export function getAwsCredentialsSet(): {
|
|
24
|
-
accessKeyId: string
|
|
25
|
-
secretAccessKey: string
|
|
26
|
-
region: string
|
|
27
|
-
} {
|
|
28
|
-
const accessKeyId = process.env.AWS_ACCESS_KEY_ID
|
|
29
|
-
const secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY
|
|
30
|
-
const region = process.env.AWS_DEFAULT_REGION
|
|
31
|
-
if (!accessKeyId || !secretAccessKey) {
|
|
32
|
-
throw new Error(
|
|
33
|
-
'AWS credentials not found, please set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables (or attach GLOBAL_ORG context if you are using CircleCI)',
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
if (!region) {
|
|
37
|
-
throw new Error(
|
|
38
|
-
'AWS region not found, please set AWS_DEFAULT_REGION environment variable (or attach GLOBAL_ORG context if you are using CircleCI)',
|
|
39
|
-
)
|
|
40
|
-
}
|
|
41
|
-
return { accessKeyId, secretAccessKey, region }
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Retrieves the authentication information for a given OIDC profile.
|
|
46
|
-
* If the specified profile exists, it fetches the configuration; otherwise, it returns false.
|
|
47
|
-
*
|
|
48
|
-
* @return {Promise<string | boolean>} The authentication details if the profile exists, or false if the profile does not exist.
|
|
49
|
-
*/
|
|
50
|
-
export async function getAuthWithOidcProfile(): Promise<string | boolean> {
|
|
51
|
-
try {
|
|
52
|
-
const profileExist = await exec_command(
|
|
53
|
-
`aws configure list-profiles | grep ${profileName}`,
|
|
54
|
-
)
|
|
55
|
-
if (profileExist.success) {
|
|
56
|
-
return profileExist.stdout
|
|
57
|
-
}
|
|
58
|
-
return false
|
|
59
|
-
} catch (e) {
|
|
60
|
-
console.error(e)
|
|
61
|
-
return false
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export async function loginToEcr() {
|
|
66
|
-
return exec_command(
|
|
67
|
-
`aws ecr get-login-password --profile ${profileName} --region eu-west-3 | ${await getDockerOrPodman()} login --username AWS --password-stdin ${process.env.AWS_ECR_REGISTRY}`,
|
|
68
|
-
)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Check AWS CLI with the OIDC profile otherwise use the default credentials
|
|
73
|
-
* @returns {string} the profile's name
|
|
74
|
-
*/
|
|
75
|
-
export async function checkAwsAuth(): Promise<string> {
|
|
76
|
-
const profileExist = await getAuthWithOidcProfile()
|
|
77
|
-
if (profileExist) {
|
|
78
|
-
console.log('OIDC profile found, using it')
|
|
79
|
-
profileName = 'OIDC-PROFILE'
|
|
80
|
-
} else if (getAwsCredentialsSet()) {
|
|
81
|
-
console.log(
|
|
82
|
-
'OIDC profile not found, using AWS_KEY_ID and AWS_SECRET_ACCESS_KEY',
|
|
83
|
-
)
|
|
84
|
-
profileName = 'default'
|
|
85
|
-
} else {
|
|
86
|
-
throw new Error(
|
|
87
|
-
'AWS credentials not found, please attach CORE-PLATFORM_SHARED_ENV context if you are using CircleCI or export AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables',
|
|
88
|
-
)
|
|
89
|
-
}
|
|
90
|
-
return profileName
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function pushImageToEcr(
|
|
94
|
-
repositoryName: string,
|
|
95
|
-
version: string,
|
|
96
|
-
): Promise<{ success: boolean }> {
|
|
97
|
-
return exec_command(
|
|
98
|
-
`docker push ${process.env.AWS_ECR_REGISTRY}/${repositoryName}:${version}`,
|
|
99
|
-
)
|
|
100
|
-
}
|
package/src/utils/exec.spec.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { exec_command } from './exec'
|
|
2
|
-
|
|
3
|
-
describe('exec', () => {
|
|
4
|
-
it('can run', async () => {
|
|
5
|
-
const output = await exec_command('echo "Hello World"')
|
|
6
|
-
expect(output.success).toBe(true)
|
|
7
|
-
expect(output.stdout).toBe('Hello World\n')
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
it('can run with stderr', async () => {
|
|
11
|
-
const output = await exec_command('echo "Hello World" 1>&2')
|
|
12
|
-
expect(output.success).toBe(false)
|
|
13
|
-
expect(output.stdout).toBe('')
|
|
14
|
-
expect(output.stderr).toBe('Hello World\n')
|
|
15
|
-
})
|
|
16
|
-
})
|
package/src/utils/exec.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { exec } from 'child_process'
|
|
2
|
-
import { promisify } from 'util'
|
|
3
|
-
|
|
4
|
-
import type { Options, TinyExec } from 'tinyexec'
|
|
5
|
-
|
|
6
|
-
import { x } from 'tinyexec'
|
|
7
|
-
|
|
8
|
-
export async function exec_command(command: string) {
|
|
9
|
-
const { stdout, stderr } = await promisify(exec)(command)
|
|
10
|
-
console.log(stdout)
|
|
11
|
-
console.error(stderr)
|
|
12
|
-
|
|
13
|
-
const success = !stderr
|
|
14
|
-
return { success, stdout, stderr }
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function createLoggingExecWrapper(execFn: TinyExec): TinyExec {
|
|
18
|
-
return (
|
|
19
|
-
command: string,
|
|
20
|
-
args: string[] = [],
|
|
21
|
-
options: Partial<Options> = {},
|
|
22
|
-
) => {
|
|
23
|
-
console.log(`Running '${command} ${args.join(' ')}'...`)
|
|
24
|
-
return execFn(command, args, {
|
|
25
|
-
throwOnError: true,
|
|
26
|
-
...options,
|
|
27
|
-
})
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const execTiny = createLoggingExecWrapper(x)
|
package/src/utils/get-version.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as fs from 'node:fs'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Get the version of a project
|
|
5
|
-
* @param projectName
|
|
6
|
-
* @returns {string}
|
|
7
|
-
*/
|
|
8
|
-
export function getVersion(projectName: string): string {
|
|
9
|
-
const versionFilePath = `dist/apps/${projectName}/VERSION`
|
|
10
|
-
return fs.readFileSync(versionFilePath, 'utf8')
|
|
11
|
-
}
|
package/src/utils/github.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { exec_command } from './exec'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Get sanitized current git branch name
|
|
5
|
-
*/
|
|
6
|
-
export async function getSanitizedCurrentGitBranch() {
|
|
7
|
-
const branchName = await exec_command(`git branch --show-current`)
|
|
8
|
-
return branchName.success
|
|
9
|
-
? branchName.stdout
|
|
10
|
-
.trim()
|
|
11
|
-
.toLowerCase()
|
|
12
|
-
.replace(/[^a-z0-9]/g, '')
|
|
13
|
-
: ''
|
|
14
|
-
}
|
package/src/utils/helm.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import * as fs from 'node:fs'
|
|
2
|
-
import * as process from 'node:process'
|
|
3
|
-
|
|
4
|
-
import { parse, stringify } from 'yaml'
|
|
5
|
-
|
|
6
|
-
import { getProfileName } from './aws-auth'
|
|
7
|
-
import { exec_command } from './exec'
|
|
8
|
-
|
|
9
|
-
const tshProxy = 'http://localhost'
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Read & parse the Helm chart.yaml file
|
|
13
|
-
* @param helmFolderPath
|
|
14
|
-
*/
|
|
15
|
-
export async function getHelmChartFile(helmFolderPath: string) {
|
|
16
|
-
return parse(fs.readFileSync(`${helmFolderPath}/Chart.yaml`, 'utf8'))
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Prepare the Chart.yaml config file for the Tsh proxy
|
|
21
|
-
* @param helmFolderPath
|
|
22
|
-
* @param tshPort
|
|
23
|
-
*/
|
|
24
|
-
export async function setupTeleportProxyHelmChartFile(
|
|
25
|
-
helmFolderPath: string,
|
|
26
|
-
tshPort: number,
|
|
27
|
-
) {
|
|
28
|
-
console.log(
|
|
29
|
-
`Replacing charts.shared.payfit.tech -> localhost:${tshPort} for the Teleport proxy`,
|
|
30
|
-
)
|
|
31
|
-
let chartConfigStr = stringify(await getHelmChartFile(helmFolderPath))
|
|
32
|
-
chartConfigStr = chartConfigStr.replace(
|
|
33
|
-
/(https?:\/\/)charts(\.shared)?\.payfit\.tech/gi,
|
|
34
|
-
`${tshProxy}:${tshPort}`,
|
|
35
|
-
)
|
|
36
|
-
return fs.writeFileSync(`${helmFolderPath}/Chart.yaml`, chartConfigStr)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Revert the Tsh proxy config in the Chart.yaml config file
|
|
41
|
-
* @param helmFolderPath
|
|
42
|
-
* @param tshPort
|
|
43
|
-
*/
|
|
44
|
-
export async function resetTeleportProxyHelmChartFile(
|
|
45
|
-
helmFolderPath: string,
|
|
46
|
-
tshPort: number,
|
|
47
|
-
) {
|
|
48
|
-
let chartConfigStr = stringify(await getHelmChartFile(helmFolderPath))
|
|
49
|
-
chartConfigStr = chartConfigStr.replace(
|
|
50
|
-
`${tshProxy}:${tshPort}`,
|
|
51
|
-
'https://charts.shared.payfit.tech',
|
|
52
|
-
)
|
|
53
|
-
return fs.writeFileSync(`${helmFolderPath}/Chart.yaml`, chartConfigStr)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Install all the helm repositories defined in the Chart config
|
|
58
|
-
* @param helmFolderPath
|
|
59
|
-
*/
|
|
60
|
-
export async function installHelmRepo(helmFolderPath: string) {
|
|
61
|
-
const chartConfig = await getHelmChartFile(helmFolderPath)
|
|
62
|
-
if (chartConfig.dependencies) {
|
|
63
|
-
for (let i = 0; i < chartConfig.dependencies.length; i++) {
|
|
64
|
-
const dep = chartConfig.dependencies[i]
|
|
65
|
-
const repoName = `tsh-${dep.name}-${dep.alias}`
|
|
66
|
-
// check if the repository is our private payfit repo or a public one
|
|
67
|
-
if (dep.repository.includes(tshProxy)) {
|
|
68
|
-
// if it's our repo, we need the username and password to authenticate
|
|
69
|
-
if (
|
|
70
|
-
!process.env.CHARTMUSEUM_USERNAME ||
|
|
71
|
-
!process.env.CHARTMUSEUM_PASSWORD
|
|
72
|
-
)
|
|
73
|
-
throw new Error(
|
|
74
|
-
'Missing CHARTMUSEUM_USERNAME, CHARTMUSEUM_PASSWORD in environment!',
|
|
75
|
-
)
|
|
76
|
-
await exec_command(
|
|
77
|
-
`helm repo add --username '${process.env.CHARTMUSEUM_USERNAME}' --password '${process.env.CHARTMUSEUM_PASSWORD}' '${repoName}' '${dep.repository}' --force-update`,
|
|
78
|
-
)
|
|
79
|
-
} else {
|
|
80
|
-
await exec_command(
|
|
81
|
-
`helm repo add '${repoName}' '${dep.repository}' --force-update`,
|
|
82
|
-
)
|
|
83
|
-
}
|
|
84
|
-
await exec_command(`helm repo update ${repoName}`)
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return exec_command(`helm dependency update ${helmFolderPath}`)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Package the Helm chart
|
|
92
|
-
* @param helmFolderPath
|
|
93
|
-
* @param version
|
|
94
|
-
* @param destinationPath
|
|
95
|
-
*/
|
|
96
|
-
export async function packageHelm(
|
|
97
|
-
helmFolderPath: string,
|
|
98
|
-
version: string,
|
|
99
|
-
destinationPath: string,
|
|
100
|
-
) {
|
|
101
|
-
return exec_command(
|
|
102
|
-
`helm package ${helmFolderPath} --version ${version} --destination ${destinationPath}`,
|
|
103
|
-
)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Push the packaged Helm chart in the chartmuseum
|
|
108
|
-
* @param packagedHelmChartFilePath
|
|
109
|
-
* @param projectName
|
|
110
|
-
* @param branch
|
|
111
|
-
*/
|
|
112
|
-
export async function pushPackagedHelm(
|
|
113
|
-
packagedHelmChartFilePath: string,
|
|
114
|
-
projectName: string,
|
|
115
|
-
branch: string,
|
|
116
|
-
) {
|
|
117
|
-
if (!process.env.CHARTMUSEUM_BUCKET_NAME)
|
|
118
|
-
throw new Error('Missing CHARTMUSEUM_BUCKET_NAME in environment!')
|
|
119
|
-
// aws s3api put-object-tagging --bucket ${process.env.CHARTMUSEUM_BUCKET_NAME} --key ${projectName}/${branch}/${packagedHelmChartFilePath} --tagging '{"TagSet": [{ "Key": "auto-purge", "Value": "false" }]}' // todo
|
|
120
|
-
const profile =
|
|
121
|
-
getProfileName() === 'default' ? '' : `--profile ${getProfileName()}`
|
|
122
|
-
return exec_command(
|
|
123
|
-
`aws s3 cp ${profile} --sse AES256 ${packagedHelmChartFilePath} s3://${process.env.CHARTMUSEUM_BUCKET_NAME}/${projectName}/${branch}/`,
|
|
124
|
-
)
|
|
125
|
-
}
|
package/src/utils/import-esm.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Needed since we have to have dynamic import to esm module, since we are stuck with cjs on the nx tool runner
|
|
2
|
-
export function importKy(): Promise<typeof import('ky')> {
|
|
3
|
-
return Function('return import("ky")')() as Promise<typeof import('ky')>
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export function importGetPort(): Promise<typeof import('get-port')> {
|
|
7
|
-
return Function('return import("get-port")')() as Promise<
|
|
8
|
-
typeof import('get-port')
|
|
9
|
-
>
|
|
10
|
-
}
|
package/src/utils/tsh.ts
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { workspaceRoot } from 'nx/src/utils/workspace-root'
|
|
2
|
-
import { z } from 'zod'
|
|
3
|
-
|
|
4
|
-
import { execTiny } from './exec'
|
|
5
|
-
import { importGetPort, importKy } from './import-esm'
|
|
6
|
-
|
|
7
|
-
const expectedProfileUrl = 'https://payfit.teleport.sh:443'
|
|
8
|
-
const expectedAppName = 'charts-shared'
|
|
9
|
-
|
|
10
|
-
const profile = z.object({
|
|
11
|
-
profile_url: z.string(),
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
const statusSchema = z.object({
|
|
15
|
-
active: profile,
|
|
16
|
-
profiles: z.array(profile).optional(),
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
const getStatusOfTsh = async () => {
|
|
20
|
-
const { stdout } = await execTiny('tsh', `status -f json`.split(' '))
|
|
21
|
-
return statusSchema.parse(JSON.parse(stdout))
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export async function isLoggedInToTsh(): Promise<boolean> {
|
|
25
|
-
try {
|
|
26
|
-
const status = await getStatusOfTsh()
|
|
27
|
-
return status.active.profile_url === expectedProfileUrl
|
|
28
|
-
} catch {
|
|
29
|
-
return false
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export async function ensureIsLoggedInToTsh(): Promise<boolean> {
|
|
34
|
-
if (await isLoggedInToTsh()) {
|
|
35
|
-
return true
|
|
36
|
-
}
|
|
37
|
-
await execTiny(
|
|
38
|
-
'tsh',
|
|
39
|
-
`login --proxy=${expectedProfileUrl} --auth=okta`.split(' '),
|
|
40
|
-
{
|
|
41
|
-
throwOnError: true,
|
|
42
|
-
},
|
|
43
|
-
)
|
|
44
|
-
return await isLoggedInToTsh()
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const getAppConfigOfTsh = async () => {
|
|
48
|
-
const { stdout } = await execTiny(
|
|
49
|
-
'tsh',
|
|
50
|
-
`apps config -f json --proxy=${expectedProfileUrl} ${expectedAppName}`.split(
|
|
51
|
-
' ',
|
|
52
|
-
),
|
|
53
|
-
{
|
|
54
|
-
throwOnError: true,
|
|
55
|
-
},
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
return JSON.parse(stdout)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export async function isConnectedToChartMuseum(): Promise<boolean> {
|
|
62
|
-
try {
|
|
63
|
-
const apps = await getAppConfigOfTsh()
|
|
64
|
-
return apps.name === expectedAppName
|
|
65
|
-
} catch {
|
|
66
|
-
return false
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export async function ensureAppIsChartMuseum(): Promise<boolean> {
|
|
71
|
-
if (await isConnectedToChartMuseum()) {
|
|
72
|
-
return true
|
|
73
|
-
}
|
|
74
|
-
await execTiny(
|
|
75
|
-
'tsh',
|
|
76
|
-
`apps login ${expectedAppName} --proxy=${expectedProfileUrl}`.split(' '),
|
|
77
|
-
{
|
|
78
|
-
throwOnError: true,
|
|
79
|
-
},
|
|
80
|
-
)
|
|
81
|
-
return await isConnectedToChartMuseum()
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export const getLocalPortForChartMuseum = async () => {
|
|
85
|
-
if (!process.env.CI) {
|
|
86
|
-
await ensureIsLoggedInToTsh()
|
|
87
|
-
await ensureAppIsChartMuseum()
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const { default: getPort } = await importGetPort()
|
|
91
|
-
const { default: ky } = await importKy()
|
|
92
|
-
const port = await getPort()
|
|
93
|
-
|
|
94
|
-
const command = process.env.CI
|
|
95
|
-
? `-i ./certs/identity --proxy payfit.teleport.sh:443 proxy app ${expectedAppName} --port ${port}`
|
|
96
|
-
: `proxy app ${expectedAppName} -p ${port}`
|
|
97
|
-
const execHandle = execTiny('tsh', command.split(' '), {
|
|
98
|
-
nodeOptions: {
|
|
99
|
-
cwd: workspaceRoot,
|
|
100
|
-
},
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
const isReady = async (): Promise<boolean> => {
|
|
104
|
-
for await (const line of execHandle) {
|
|
105
|
-
console.log(`[TSH] ${line}`)
|
|
106
|
-
if (line.includes('Proxying connections')) {
|
|
107
|
-
return true
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
// line will be from stderr/stdout in the order you'd see it in a term
|
|
111
|
-
return false
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const fetchClient = ky.create({
|
|
115
|
-
prefixUrl: `http://localhost:${port}`,
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
return {
|
|
119
|
-
[Symbol.dispose]: async () => {
|
|
120
|
-
console.log(`Terminating tsh proxy on port ${port}`)
|
|
121
|
-
execHandle.kill()
|
|
122
|
-
},
|
|
123
|
-
fetchClient,
|
|
124
|
-
isReady,
|
|
125
|
-
port,
|
|
126
|
-
}
|
|
127
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"esModuleInterop": true,
|
|
6
|
-
"target": "es2022",
|
|
7
|
-
"lib": ["es2022", "esnext.disposable", "dom"]
|
|
8
|
-
},
|
|
9
|
-
"files": [],
|
|
10
|
-
"include": [],
|
|
11
|
-
"references": [
|
|
12
|
-
{
|
|
13
|
-
"path": "./tsconfig.lib.json"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"path": "./tsconfig.spec.json"
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
package/tsconfig.lib.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "./dist/out-tsc",
|
|
5
|
-
"tsBuildInfoFile": "./dist/out-tsc.tsbuildinfo"
|
|
6
|
-
},
|
|
7
|
-
"include": ["src/**/*.ts"],
|
|
8
|
-
"exclude": [
|
|
9
|
-
"vite.config.ts",
|
|
10
|
-
"vite.config.mts",
|
|
11
|
-
"vitest.config.ts",
|
|
12
|
-
"vitest.config.mts",
|
|
13
|
-
"src/**/*.test.ts",
|
|
14
|
-
"src/**/*.spec.ts",
|
|
15
|
-
"src/**/*.test.tsx",
|
|
16
|
-
"src/**/*.spec.tsx",
|
|
17
|
-
"src/**/*.test.js",
|
|
18
|
-
"src/**/*.spec.js",
|
|
19
|
-
"src/**/*.test.jsx",
|
|
20
|
-
"src/**/*.spec.jsx"
|
|
21
|
-
]
|
|
22
|
-
}
|
package/tsconfig.spec.json
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "dist",
|
|
5
|
-
"types": [
|
|
6
|
-
"vitest/globals",
|
|
7
|
-
"vitest/importMeta",
|
|
8
|
-
"vite/client",
|
|
9
|
-
"node",
|
|
10
|
-
"vitest"
|
|
11
|
-
]
|
|
12
|
-
},
|
|
13
|
-
"include": [
|
|
14
|
-
"vite.config.ts",
|
|
15
|
-
"vite.config.mts",
|
|
16
|
-
"vitest.config.ts",
|
|
17
|
-
"vitest.config.mts",
|
|
18
|
-
"src/**/*.test.ts",
|
|
19
|
-
"src/**/*.spec.ts",
|
|
20
|
-
"src/**/*.test.tsx",
|
|
21
|
-
"src/**/*.spec.tsx",
|
|
22
|
-
"src/**/*.test.js",
|
|
23
|
-
"src/**/*.spec.js",
|
|
24
|
-
"src/**/*.test.jsx",
|
|
25
|
-
"src/**/*.spec.jsx",
|
|
26
|
-
"src/**/*.d.ts"
|
|
27
|
-
]
|
|
28
|
-
}
|
package/vite.config.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin'
|
|
2
|
-
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'
|
|
3
|
-
import { defineConfig, loadEnv } from 'vite'
|
|
4
|
-
|
|
5
|
-
export default defineConfig(({ mode }) => ({
|
|
6
|
-
root: __dirname,
|
|
7
|
-
cacheDir: '../../node_modules/.vite/tools/publisher',
|
|
8
|
-
plugins: [nxViteTsPaths(), nxCopyAssetsPlugin(['*.md'])],
|
|
9
|
-
// Uncomment this if you are using workers.
|
|
10
|
-
// worker: {
|
|
11
|
-
// plugins: [ nxViteTsPaths() ],
|
|
12
|
-
// },
|
|
13
|
-
test: {
|
|
14
|
-
watch: false,
|
|
15
|
-
globals: true,
|
|
16
|
-
environment: 'jsdom',
|
|
17
|
-
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
18
|
-
reporters: ['default', 'junit'],
|
|
19
|
-
outputFile: {
|
|
20
|
-
junit: '../../test-results/vitest-results.xml',
|
|
21
|
-
},
|
|
22
|
-
coverage: {
|
|
23
|
-
reportsDirectory: '../../coverage/packages/nx-core',
|
|
24
|
-
provider: 'v8' as const,
|
|
25
|
-
},
|
|
26
|
-
env: loadEnv(mode, process.cwd(), ''),
|
|
27
|
-
},
|
|
28
|
-
}))
|
|
File without changes
|
|
File without changes
|