-
Notifications
You must be signed in to change notification settings - Fork 23
π Add command to increase project version and implement version increment logic, Closes #94 #387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e09e726
π Enhance error handling in PromptHandlers to display error messages β¦
nicodecleyre 8a6183e
π Adds 'Set Form Customizer' command to the SharePoint Framework Toolβ¦
nicodecleyre 3dfc574
π Enhance progress notifications with output window links for better β¦
nicodecleyre 4c021e3
Pre-Release v4.3.1
Adam-it 2da4000
π Add command to increase project version and implement version increβ¦
nicodecleyre 88739b7
Install, Uninstall apps to a specified site. Closes #350 (#390)
Saurabh7019 d5f7b3a
Pre-Release v4.3.2
Adam-it 9ca8890
π₯ Update icon for increase version command and enhance package solutiβ¦
nicodecleyre 8d7490c
Merge branch 'dev' into increase-version-number
nicodecleyre 02c0ab6
Add the increase version number as a new command
Adam-it 893d15f
clean-up
Adam-it 6c4a2ef
Merge branch 'dev' into increase-version-number
nicodecleyre f09ca59
Fixup
Adam-it f908823
Updates to handle Teams Toolkit scenario with 3 package.json
Adam-it File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { readFileSync, writeFileSync } from 'fs'; | ||
import { join } from 'path'; | ||
import { workspace } from 'vscode'; | ||
import { TeamsToolkitIntegration } from '../services/dataType/TeamsToolkitIntegration'; | ||
|
||
|
||
export async function increaseVersion(versionType: 'major' | 'minor' | 'patch') { | ||
const wsFolder = workspace.workspaceFolders?.[0]; | ||
if (!wsFolder) { | ||
throw new Error('Workspace folder not found'); | ||
} | ||
|
||
let packageSolutionFiles = []; | ||
if (TeamsToolkitIntegration.isTeamsToolkitProject) { | ||
packageSolutionFiles = await workspace.findFiles('src/config/package-solution.json', '**/node_modules/**'); | ||
} else { | ||
packageSolutionFiles = await workspace.findFiles('config/package-solution.json', '**/node_modules/**'); | ||
} | ||
|
||
const packageSolutionPath = packageSolutionFiles[0].fsPath; | ||
const packageSolution = JSON.parse(readFileSync(packageSolutionPath, 'utf8')); | ||
|
||
const packageJsonPath = join(wsFolder.uri.fsPath, 'package.json'); | ||
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8')); | ||
|
||
const newVersion = incrementVersion(packageJson.version, versionType); | ||
packageJson.version = newVersion; | ||
packageSolution.solution.version = `${newVersion}.0`; | ||
|
||
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2)); | ||
writeFileSync(packageSolutionPath, JSON.stringify(packageSolution, null, 2)); | ||
|
||
if (TeamsToolkitIntegration.isTeamsToolkitProject) { | ||
const packageJsonSrcPath = join(wsFolder.uri.fsPath, 'src', 'package.json'); | ||
const packageJsonSrc = JSON.parse(readFileSync(packageJsonPath, 'utf8')); | ||
packageJsonSrc.version = newVersion; | ||
writeFileSync(packageJsonSrcPath, JSON.stringify(packageJsonSrc, null, 2)); | ||
} | ||
} | ||
|
||
function incrementVersion(version: string, versionType: 'major' | 'minor' | 'patch'): string { | ||
const [major, minor, patch] = version.split('.').map(Number); | ||
|
||
switch (versionType) { | ||
case 'major': | ||
return `${major + 1}.0.0`; | ||
case 'minor': | ||
return `${major}.${minor + 1}.0`; | ||
case 'patch': | ||
return `${major}.${minor}.${patch + 1}`; | ||
default: | ||
throw new Error('Invalid version type'); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.