Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions ci/build-common-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ jobs:
- script: npm i -g [email protected] --force
displayName: Use npm version 8.19.4

- script: |
npm install
- script: npm install
displayName: Npm install

- script: |
npm run build
- script: node ./ci/check-versions.js
displayName: Verify tasks' versions
condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/main'))

- script: npm run build
displayName: Build Common Npm packages

- script: |
node ./ci/verify-source-changes.js
- script: node ./ci/verify-source-changes.js
displayName: Verify task source changes
condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/main'))

- script: |
npm run test
- script: npm run test
displayName: Test Common Npm packages

- task: PublishTestResults@2
Expand All @@ -48,8 +48,7 @@ jobs:
summaryFileLocation: $(System.DefaultWorkingDirectory)/test-results/*coverage.xml

# For CI runs on master, automatically publish packages
- bash: |
npm run publish
- bash: npm run publish
condition: and(succeeded(), in(variables['build.reason'], 'IndividualCI', 'BatchedCI', 'Manual'), eq(variables['Agent.OS'], 'Windows_NT'))
env:
NPM_TOKEN: $(npm-automation.token)
Expand Down
92 changes: 92 additions & 0 deletions ci/check-versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
const { execSync } = require('node:child_process');
const { readFileSync } = require('node:fs');
const { join } = require('node:path');
const { styleText } = require('node:util');

const packages = [
'artifacts-common',
'az-blobstorage-provider',
'azure-arm-rest',
'azurermdeploycommon',
'codeanalysis-common',
'codecoverage-tools',
'docker-common',
'ios-signing-common',
'java-common',
'kubernetes-common',
'msbuildhelpers',
'packaging-common',
'securefiles-common',
'utility-common',
'webdeployment-common',
];

const gitDiffResult = execSync('git --no-pager diff --name-only origin/master', { encoding: 'utf8' }).split('\n');
const changedFolders = new Set();

for (const filePath of gitDiffResult) {
for (const pkg of packages) {
// Check if the file path starts with the package folder name
if (filePath.startsWith(`common-npm-packages/${pkg}/`)) {
changedFolders.add(pkg);
}
}
}

if (changedFolders.size > 0) {
const errors = [];

for (const pkg of changedFolders) {
const pkgJsonPath = join(__dirname, '../common-npm-packages', pkg, 'package.json');
try {
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, 'utf8'));
const currentVersion = pkgJson.version;
// Get package.json from main branch
let mainVersion = null;
try {
const mainPkgJsonRaw = execSync(`git show main:common-npm-packages/${pkg}/package.json`, { encoding: 'utf8' });
const mainPkgJson = JSON.parse(mainPkgJsonRaw);
mainVersion = mainPkgJson.version;
} catch (err) {
// If package.json doesn't exist in main, treat as new package
}

if (mainVersion && compareVersions(mainVersion, currentVersion) >= 0) {
errors.push({
pkg,
mainVersion,
currentVersion
});
}
} catch (err) {
console.warn(`Could not read version for ${pkg}:`, err.message);
}
}
if (errors.length > 0) {
console.error(styleText('red', 'Error: The following packages have not been updated correctly:'));
errors.forEach(error => {
console.error(`Local version ${styleText('green', error.currentVersion)} <= main version ${styleText('redBright', error.mainVersion)} for package ${styleText('blueBright', error.pkg)}.`);
});
process.exit(1);
}
} else {
console.log('No changed package folders detected.');
}

/**
* Compare two semver strings. Returns 1 if a > b, 0 if a == b, -1 if a < b
* @param {string} a - The first version string to compare
* @param {string} b - The second version string to compare
* @returns
*/
function compareVersions(a, b) {
const pa = a.split('.').map(Number);
const pb = b.split('.').map(Number);
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
const na = pa[i] || 0;
const nb = pb[i] || 0;
if (na > nb) return 1;
if (na < nb) return -1;
}
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function replaceMultiple(text: string, substitutions: any): string {
return text;
}


function addMissingParametersValue(appType: string, webConfigParameters) {
var paramDefaultValue = {
'node': {
Expand Down Expand Up @@ -95,14 +96,14 @@ export function addWebConfigFile(folderPath: any, webConfigParameters, rootDirec
}
} else if(appType == 'Go') {
if (util.isNullOrUndefined(webConfigParameters['GoExeFileName'])
|| util.isNullOrUndefined(webConfigParameters['GoExeFileName'].value)
|| util.isNullOrUndefined(webConfigParameters['GoExeFileName'].value)
|| webConfigParameters['GoExeFileName'].value.length <=0) {
throw Error(tl.loc('GoExeNameNotPresent'));
}
selectedAppTypeParams['GoExeFilePath'] = rootDirectoryPath + "\\" + webConfigParameters['GoExeFileName'].value;
} else if(appType == 'java_springboot') {
if (util.isNullOrUndefined(webConfigParameters['JAR_PATH'])
|| util.isNullOrUndefined(webConfigParameters['JAR_PATH'].value)
|| util.isNullOrUndefined(webConfigParameters['JAR_PATH'].value)
|| webConfigParameters['JAR_PATH'].value.length <= 0) {
throw Error(tl.loc('JarPathNotPresent'));
}
Expand Down
17 changes: 17 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noEmit": true,
"skipLibCheck": true,
"allowJs": true,
"checkJs": true,
"useUnknownInCatchVariables": false
},
"include": [
"ci"
]
}
Loading