Skip to content

Commit

Permalink
renamed mock => local
Browse files Browse the repository at this point in the history
  • Loading branch information
arturcic committed Jul 9, 2024
1 parent c50e031 commit 888e169
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ dist-ssr
.taskkey
*.vsix

/dist/mock/
/dist/local/

.debug/
14 changes: 7 additions & 7 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
{
"type": "node",
"request": "launch",
"preLaunchTask": "Build-Mock",
"name": "Debug Mock Setup GitVersion",
"program": "${workspaceFolder}/dist/mock/gitversion/setup/bundle.js",
"preLaunchTask": "Build-Local",
"name": "Debug Local Setup GitVersion",
"program": "${workspaceFolder}/dist/local/gitversion/setup/bundle.js",
"outFiles": [ "${workspaceFolder}/**/*.js" ]
},
{
Expand All @@ -31,9 +31,9 @@
{
"type": "node",
"request": "launch",
"preLaunchTask": "Build-Mock",
"name": "Debug Mock Execute GitVersion",
"program": "${workspaceFolder}/dist/mock/gitversion/execute/bundle.js",
"preLaunchTask": "Build-Local",
"name": "Debug Local Execute GitVersion",
"program": "${workspaceFolder}/dist/local/gitversion/execute/bundle.js",
"outFiles": [ "${workspaceFolder}/**/*.js" ]
},
{
Expand All @@ -53,4 +53,4 @@
"outFiles": [ "${workspaceFolder}/**/*.js" ]
},
]
}
}
6 changes: 3 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"version": "2.0.0",
"tasks": [
{
"label": "Build-Mock",
"label": "Build-Local",
"type": "npm",
"script": "build:mock"
"script": "build:local"
},
{
"label": "Build-Azure",
Expand All @@ -19,4 +19,4 @@
"script": "build:github"
},
]
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"node": ">=20.0.0"
},
"scripts": {
"build": "npm run build:agent:mock && npm run build:agent:azure && npm run build:agent:github",
"build": "npm run build:agent:local && npm run build:agent:azure && npm run build:agent:github",
"format": "prettier --write src/**/*.ts",
"format-check": "prettier --check src/**/*.ts",
"build:agent:mock": "webpack --config webpack.config.js --env agent=mock",
"build:agent:local": "webpack --config webpack.config.js --env agent=local",
"build:agent:azure": "webpack --config webpack.config.js --env agent=azure",
"build:agent:github": "webpack --config webpack.config.js --env agent=github",
"publish:azure": "tfx extension publish --root ./dist/azure --no-wait-validation --auth-type pat"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BuildAgent implements IBuildAgent {
}
public get agentName(): string {
console.log('getAgentName')
return 'Mock'
return 'Local'
}

public find(toolName: string, versionSpec: string, arch?: string): string {
Expand Down
2 changes: 1 addition & 1 deletion src/core/ioc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Container } from 'inversify'
import { IVersionManager, VersionManager } from './versionManager'
import { TYPES, IBuildAgent } from './models'
import { BuildAgent } from '../agents/mock/build-agent'
import { BuildAgent } from '../agents/local/build-agent'

const container = new Container()

Expand Down
78 changes: 41 additions & 37 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path');
const webpack = require('webpack');
const ReplaceInFileWebpackPlugin = require('replace-in-file-webpack-plugin');
const path = require('path')
const webpack = require('webpack')
const ReplaceInFileWebpackPlugin = require('replace-in-file-webpack-plugin')

function getConfig(mode, agent, entry) {
return {
Expand All @@ -9,40 +9,44 @@ function getConfig(mode, agent, entry) {
mode: mode,
devtool: mode === 'development' ? 'inline-source-map' : false,
module: {
rules: [{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
}],
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.json'],
extensions: ['.tsx', '.ts', '.js', '.json']
},
output: {
libraryTarget: 'commonjs2',
filename: '[name]/bundle.js',
path: path.resolve(__dirname, `dist/${agent}`),
path: path.resolve(__dirname, `dist/${agent}`)
},
node: {
__dirname: false,
__filename: false
},
plugins: [
new webpack.NormalModuleReplacementPlugin(
/agents\/mock\/build-agent/,
`../agents/${agent}/build-agent`
),
new ReplaceInFileWebpackPlugin([{
dir: `dist/${agent}`,
test: /bundle.js/,
rules: [{
search: /__webpack_require__\(.*\)\(resourceFile\)/,
replace: '_loadResJson(resourceFile)'
}, {
search: /let pkg.*'package.json'\)\);/,
replace: 'let pkg = { version: "1.2.3" };'
}]
}])
new webpack.NormalModuleReplacementPlugin(/agents\/local\/build-agent/, `../agents/${agent}/build-agent`),
new ReplaceInFileWebpackPlugin([
{
dir: `dist/${agent}`,
test: /bundle.js/,
rules: [
{
search: /__webpack_require__\(.*\)\(resourceFile\)/,
replace: '_loadResJson(resourceFile)'
},
{
search: /let pkg.*'package.json'\)\);/,
replace: 'let pkg = { version: "1.2.3" };'
}
]
}
])
],
experiments: {
topLevelAwait: true
Expand All @@ -59,18 +63,18 @@ const entryPoints = [
'gitreleasemanager/close',
'gitreleasemanager/open',
'gitreleasemanager/publish',
'gitreleasemanager/addasset',
];
'gitreleasemanager/addasset'
]

module.exports = (env) => {
const task = env.task || 'compile';
const agent = env.agent || 'mock';
const mode = task === 'compile' ? 'development' : 'production';
const entry = {};
module.exports = env => {
const task = env.task || 'compile'
const agent = env.agent || 'local'
const mode = task === 'compile' ? 'development' : 'production'
const entry = {}
entryPoints.forEach(key => {
const resource = task === 'compile' ? `src/tasks/${key}.ts` : `dist/${agent}/${key}/bundle.js`;
entry[key] = path.resolve(__dirname, resource);
});
const resource = task === 'compile' ? `src/tasks/${key}.ts` : `dist/${agent}/${key}/bundle.js`
entry[key] = path.resolve(__dirname, resource)
})

return getConfig(mode, agent, entry);
};
return getConfig(mode, agent, entry)
}

0 comments on commit 888e169

Please sign in to comment.