Skip to content

Commit

Permalink
Split programming model out of worker (#608)
Browse files Browse the repository at this point in the history
  • Loading branch information
ejizba committed Aug 18, 2022
1 parent 8fb05a8 commit 34655ab
Show file tree
Hide file tree
Showing 48 changed files with 710 additions and 3,722 deletions.
26 changes: 0 additions & 26 deletions azure-pipelines/build.yml
Expand Up @@ -68,38 +68,12 @@ jobs:
publishVstsFeed: 'e6a70c92-4128-439f-8012-382fe78d6396/f37f760c-aebd-443e-9714-ce725cd427df'
allowPackageConflicts: true
displayName: 'Push NuGet package to the AzureFunctionsPreRelease feed'
# In order for the SBOM to be accurate, we want to explicitly specify the components folder, but the types package doesn't have any components
# We'll create an empty folder that _would_ store the components if it had any
- bash: |
mkdir types/node_modules
displayName: 'mkdir types/node_modules'
- task: CopyFiles@2
displayName: 'Copy types files to staging'
inputs:
sourceFolder: '$(Build.SourcesDirectory)/types'
contents: |
index.d.ts
LICENSE
package.json
README.md
targetFolder: '$(Build.ArtifactStagingDirectory)/types'
cleanTargetFolder: true
- task: ManifestGeneratorTask@0
displayName: 'Generate SBOM for types'
inputs:
BuildDropPath: '$(Build.ArtifactStagingDirectory)/types'
BuildComponentPath: '$(Build.SourcesDirectory)/types/node_modules'
PackageName: 'Azure Functions Type Definitions'
- script: npm pack
displayName: 'npm pack types'
workingDirectory: '$(Build.ArtifactStagingDirectory)/types'
- task: CopyFiles@2
displayName: 'Copy packages to staging drop folder'
inputs:
sourceFolder: '$(Build.ArtifactStagingDirectory)'
contents: |
worker/*.nupkg
types/*.tgz
targetFolder: '$(Build.ArtifactStagingDirectory)/drop'
cleanTargetFolder: true
- task: PublishPipelineArtifact@1
Expand Down
43 changes: 0 additions & 43 deletions azure-pipelines/release-types.yml

This file was deleted.

65 changes: 28 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions package.json
Expand Up @@ -5,13 +5,12 @@
"description": "Microsoft Azure Functions NodeJS Worker",
"license": "(MIT OR Apache-2.0)",
"dependencies": {
"@azure/functions": "^3.5.0-alpha.1",
"@grpc/grpc-js": "^1.2.7",
"@grpc/proto-loader": "^0.6.4",
"blocked-at": "^1.2.0",
"fs-extra": "^10.0.1",
"long": "^4.0.0",
"minimist": "^1.2.5",
"uuid": "^8.3.0"
"minimist": "^1.2.5"
},
"devDependencies": {
"@types/blocked-at": "^1.0.1",
Expand Down Expand Up @@ -49,8 +48,6 @@
"sinon": "^7.0.0",
"ts-node": "^3.3.0",
"typescript": "^4.5.5",
"typescript3": "npm:typescript@~3.7.0",
"typescript4": "npm:typescript@~4.0.0",
"webpack": "^5.72.1",
"webpack-cli": "^4.8.0"
},
Expand All @@ -64,13 +61,13 @@
},
"scripts": {
"clean": "rimraf dist && rimraf azure-functions-language-worker-protobuf/src/rpc*",
"build": "rimraf dist && npm run gen && shx mkdir -p dist/azure-functions-language-worker-protobuf/src && shx cp azure-functions-language-worker-protobuf/src/rpc.* dist/azure-functions-language-worker-protobuf/src/. && node ./node_modules/typescript/bin/tsc",
"build": "rimraf dist && npm run gen && shx mkdir -p dist/azure-functions-language-worker-protobuf/src && shx cp azure-functions-language-worker-protobuf/src/rpc.* dist/azure-functions-language-worker-protobuf/src/. && tsc",
"gen": "node scripts/generateProtos.js",
"test": "mocha -r ts-node/register \"./test/**/*.ts\" --reporter mocha-multi-reporters --reporter-options configFile=test/mochaReporterOptions.json",
"lint": "eslint .",
"lint-fix": "eslint . --fix",
"updateVersion": "ts-node ./scripts/updateVersion.ts",
"watch": "node ./node_modules/typescript/bin/tsc --watch",
"watch": "tsc --watch",
"webpack": "webpack --mode production"
},
"files": [
Expand Down
31 changes: 2 additions & 29 deletions scripts/updateVersion.ts
Expand Up @@ -9,8 +9,6 @@ import * as semver from 'semver';

const repoRoot = path.join(__dirname, '..');
const packageJsonPath = path.join(repoRoot, 'package.json');
const typesRoot = path.join(repoRoot, 'types');
const typesPackageJsonPath = path.join(typesRoot, 'package.json');
const nuspecPath = path.join(repoRoot, 'Worker.nuspec');
const nuspecVersionRegex = /<version>(.*)\$prereleaseSuffix\$<\/version>/i;
const constantsPath = path.join(repoRoot, 'src', 'constants.ts');
Expand All @@ -24,9 +22,6 @@ if (args.validate) {
} else {
console.log(`This script can be used to either update the version of the worker or validate that the repo is in a valid state with regards to versioning.
NOTE: For the types package, only the major & minor version need to match the worker. We follow the same pattern as DefinitelyTyped as described here:
https://github.com/DefinitelyTyped/DefinitelyTyped#how-do-definitely-typed-package-versions-relate-to-versions-of-the-corresponding-library
Example usage:
npm run updateVersion -- --version 3.3.0
Expand All @@ -39,35 +34,21 @@ function validateVersion() {
const packageJson = readJSONSync(packageJsonPath);
const packageJsonVersion = packageJson.version;

const typesPackageJson = readJSONSync(typesPackageJsonPath);
const typesPackageJsonVersion = typesPackageJson.version;

const nuspecVersion = getVersion(nuspecPath, nuspecVersionRegex);

const constantsVersion = getVersion(constantsPath, constantsVersionRegex);

console.log('Found the following versions:');
console.log(`- package.json: ${packageJsonVersion}`);
console.log(`- types/package.json: ${typesPackageJsonVersion}`);
console.log(`- Worker.nuspec: ${nuspecVersion}`);
console.log(`- src/constants.ts: ${constantsVersion}`);

const parsedVersion = semver.parse(packageJsonVersion);
const parsedTypesVersion = semver.parse(typesPackageJsonVersion);

if (
!packageJsonVersion ||
!nuspecVersion ||
!constantsVersion ||
!typesPackageJsonVersion ||
!parsedVersion ||
!parsedTypesVersion
) {

if (!packageJsonVersion || !nuspecVersion || !constantsVersion || !parsedVersion) {
throw new Error('Failed to detect valid versions in all expected files');
} else if (nuspecVersion !== packageJsonVersion || constantsVersion !== packageJsonVersion) {
throw new Error(`Worker versions do not match.`);
} else if (parsedVersion.major !== parsedTypesVersion.major || parsedVersion.minor !== parsedTypesVersion.minor) {
throw new Error(`Types package does not match the major/minor version of the worker.`);
} else {
console.log('Versions match! 🎉');
}
Expand All @@ -84,15 +65,7 @@ function getVersion(filePath: string, regex: RegExp): string {

function updateVersion(newVersion: string) {
updatePackageJsonVersion(repoRoot, newVersion);

if (newVersion.endsWith('.0')) {
updatePackageJsonVersion(typesRoot, newVersion);
} else {
console.log(`Skipping types/package.json because this is a patch version.`);
}

updateVersionByRegex(nuspecPath, nuspecVersionRegex, newVersion);

updateVersionByRegex(constantsPath, constantsVersionRegex, newVersion);
}

Expand Down

0 comments on commit 34655ab

Please sign in to comment.