Skip to content

Commit

Permalink
Merge pull request #68 from saertna/ReleaseNotes
Browse files Browse the repository at this point in the history
Show Release notes
  • Loading branch information
saertna authored Feb 18, 2024
2 parents 6e2194a + 30053a1 commit 445d384
Show file tree
Hide file tree
Showing 16 changed files with 1,023 additions and 76 deletions.
735 changes: 729 additions & 6 deletions package-lock.json

Large diffs are not rendered by default.

38 changes: 27 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
"description": "Enhance your Personal Knowledge Management with gamification elements. Boost motivation and achieve growth as you engage with your PKM.",
"main": "main.js",
"scripts": {
"dev": "node esbuild.config.mjs",
"dev": "rollup --config rollup.config.js -w",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"rbuild": "rollup --config rollup.config.js",
"dev2": "node esbuild.config.mjs --config rollup.config.js -w",
"version": "node version-bump.mjs && git add manifest.json versions.json",
"lint:js": "eslint *.js",
"lint": "npm run lint:js",
Expand All @@ -15,7 +17,24 @@
"keywords": [],
"author": "Andreas Trebing",
"license": "MIT",
"dependencies": {
"crypto-js": "^4.1.1",
"date-fns": "^2.30.0",
"markdown-it": "^13.0.1",
"moment": "^2.29.4",
"obsidian-dataview": "^0.4.21",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"ts-node": "^10.9.1"
},
"devDependencies": {
"@jridgewell/sourcemap-codec": "^1.4.15",
"@rollup/plugin-commonjs": "^24.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.5",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.2",
"@types/crypto-js": "^4.1.1",
"@types/jest": "^29.5.4",
"@types/node": "^16.11.6",
"@types/react": "^18.2.0",
Expand All @@ -30,18 +49,15 @@
"lint": "^1.1.2",
"markdownlint": "^0.30.0",
"obsidian": "^1.4.11",
"rollup": "^2.79.1",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-postprocess": "github:brettz9/rollup-plugin-postprocess#update",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.34.1",
"ts-jest": "^29.1.1",
"tslib": "2.4.0",
"typescript": "4.7.4"
},
"dependencies": {
"crypto-js": "^4.1.1",
"date-fns": "^2.30.0",
"markdown-it": "^13.0.1",
"moment": "^2.29.4",
"obsidian-dataview": "^0.4.21",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"ts-node": "^10.9.1"
}
}
54 changes: 33 additions & 21 deletions preprelease.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,32 @@ def update_json_version(file_path, new_version):
with open(file_path, 'w') as json_file:
json.dump(data, json_file, indent=2)

#def zip_files(source_folder, output_zip_path):
# with shutil.ZipFile(output_zip_path, 'w') as zip_file:
# for root, dirs, files in os.walk(source_folder):
# for file in files:
# file_path = os.path.join(root, file)
# arcname = os.path.relpath(file_path, source_folder)
# zip_file.write(file_path, arcname=arcname)

def update_constants(constants_path):




def update_constants_false(constants_path):
with open(constants_path, 'r', encoding='utf-8') as constants_file:
constants_content = constants_file.read()

updated_constants_content = constants_content.replace('export const debugLogs = true;', 'export const debugLogs = false;')

with open(constants_path, 'w', encoding='utf-8') as constants_file:
constants_file.write(updated_constants_content)

def update_constants(constants_path, new_version):
with open(constants_path, 'r', encoding='utf-8') as constants_file:
constants_content = constants_file.read()
constants_lines = constants_file.readlines()

updated_constants_content = constants_content.replace('export const debugLogs = true;', 'export const debugLogs = false;')
# Find the line containing the version string
for i, line in enumerate(constants_lines):
if 'export const PLUGIN_VERSION' in line:
old_version = line.split('=')[1].strip().strip(';').strip("'")
constants_lines[i] = line.replace(old_version, new_version)

# Write the updated content back to the file
with open(constants_path, 'w', encoding='utf-8') as constants_file:
constants_file.write(updated_constants_content)
constants_file.writelines(constants_lines)

def main(new_version):
plugin_folder = '.'
Expand All @@ -94,8 +104,10 @@ def main(new_version):
update_json_version(package_path, new_version)

# Update constants.ts
update_constants(constants_path)

print(constants_path)
update_constants(constants_path, new_version)
update_constants_false(constants_path)

# Run npm build commands
try:
subprocess.run(["npm", "install"], check=True, cwd=plugin_folder, shell=True)
Expand All @@ -104,19 +116,19 @@ def main(new_version):
print(f"Error running npm commands: {e}")

# Zip files
files_to_zip = ['main.js', 'manifest.json', 'styles.css']
zip_folder = os.path.join(plugin_folder, f'obsidian-gamified-pkm.zip')
zip_files(plugin_folder, zip_folder, files_to_zip)
# files_to_zip = ['main.js', 'manifest.json', 'styles.css']
# zip_folder = os.path.join(plugin_folder, f'obsidian-gamified-pkm.zip')
# zip_files(plugin_folder, zip_folder, files_to_zip)

# Move the zip archive to the 'install-zip' subfolder
install_zip_folder = os.path.join(plugin_folder, 'obsidian-gamified-pkm')
os.makedirs(install_zip_folder, exist_ok=True)
# install_zip_folder = os.path.join(plugin_folder, 'obsidian-gamified-pkm')
# os.makedirs(install_zip_folder, exist_ok=True)

# Create the new path for the zip archive in the 'install-zip' folder
new_zip_path = os.path.join(install_zip_folder, f'obsidian-gamified-pkm.zip')
# new_zip_path = os.path.join(install_zip_folder, f'obsidian-gamified-pkm.zip')

# Move the zip archive
shutil.move(zip_folder, new_zip_path)
# shutil.move(zip_folder, new_zip_path)

if __name__ == "__main__":
new_version = input("Enter the new version: ")
Expand Down
52 changes: 52 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import replace from "@rollup/plugin-replace";
import typescript from "rollup-plugin-typescript2";
import resolve from '@rollup/plugin-node-resolve';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import fs from 'fs';

const manifestStr = fs.readFileSync("manifest.json", "utf-8");
const manifest = JSON.parse(manifestStr);

const packageString = `const PLUGIN_VERSION = "${manifest.version}";`;

export default {
input: 'src/main.ts',
output: {
file: 'main.js',
format: 'cjs',
exports: 'auto'
},
external: ['obsidian', 'crypto-js'],
plugins: [
resolve(),
nodeResolve(),
typescript({
inlineSourceMap: true, // Ensure inline source map is generated
inlineSources: true, // Ensure inline sources are included
tsconfig: "tsconfig.json", // Specify the path to your tsconfig.json file
abortOnError: false // Continue bundling even if there are TypeScript errors
}),
{
name: 'debug-log',
// Add a console log before the replace plugin
buildStart() {
console.log('Starting Rollup build...');
}
},
replace({
preventAssignment: true,
values: {
// Replace the declaration of PLUGIN_VERSION directly
'declare const PLUGIN_VERSION: string;': packageString
}
}),
{
name: 'debug-log',
// Add a console log after the replace plugin
buildEnd() {
console.log('Rollup build completed.');
console.log(`packageString content: ${packageString}`)
}
}
]
};
2 changes: 0 additions & 2 deletions src/GamificationMediator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export interface GamificationMediator {
//updateIncrementStock(increment: string, stock: number): void;

getSettingNumber(key: string):number;
getSettingString(key: string): string;

Expand Down
39 changes: 39 additions & 0 deletions src/Messages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
export const FIRST_TIME = `
Imagine transforming your knowledge management into an adventure where every step forward is a celebration. Introducing the Obsidian Gamification Plugin – a tool designed to harness the motivating power of game techniques and apply it to our pursuit of knowledge.
This plugin reimagines the way we interact with our knowledge base. By integrating game-like elements, it offers rewards for your progress, nurtures consistency, and makes the journey of learning a truly motivating experience. From achieving milestones to conquering challenges that shape your learning path, this plugin adds a layer of excitement to your knowledge management process.
Thank you & Enjoy!
`;

export const RELEASE_NOTES: { [k: string]: string } = {
Intro: `After each update you'll be prompted with the release notes. You can disable this in plugin settings.
I develop this plugin as a hobby, spending my free time doing this. If you find it valuable, then please say THANK YOU or...
<div class="ex-coffee-div"><a href="https://ko-fi.com/andreastrebing"><img src="https://cdn.ko-fi.com/cdn/kofi3.png?v=3" height=45></a></div>
`,
"0.0.89": `
## New
- Introduction to Release Note showcase
- Added automatic triggering of rate, can be enabled in settings`,
"0.0.88":`
## Changed
- Support more levels, up to 200, and fix incorrect calculations
- Make layer 2 and layer 3 in 'progressive summarization' score more accurate`,
"0.0.87":`
## New
- check for new available version`,
"0.0.86":`
## New
- support for mobile devices`,
"0.0.85":`
## New
- Store received Badges for recover possibility`,
"0.0.84":`
## Improved
- Formating booster board by`,
"0.0.8":`
## Start
- First Release for the gamified personal knowledge management in Obsidian!`,
};
9 changes: 9 additions & 0 deletions src/ModalBooster.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
import { App, Modal } from 'obsidian';
import gamification from 'main';
import { MultiSelectModal } from 'MultiSelectModal';
import { GamificationMediator } from './GamificationMediator';

export class ModalBooster extends Modal {
private readonly displayText: string;
private readonly gamificationInstance: gamification;
private readonly mediator: GamificationMediator;

constructor(app: App, displayText: string, gamificationInstance: gamification) {
super(app);
this.displayText = displayText;
this.gamificationInstance = gamificationInstance;
}

// constructor(app: App, displayText: string, mediator: GamificationMediator) {
// super(app);
// this.displayText = displayText;
// this.mediator = mediator;
// }

onOpen() {
const { contentEl } = this;
contentEl.setText(this.displayText);


const multiSelectModal = new MultiSelectModal(this.app, [], 'Craft Booster Item', this.gamificationInstance); // Create the modal instance
//const multiSelectModal = new MultiSelectModal(this.app, [], 'Craft Booster Item', this.mediator);


const button = document.createElement('button');
Expand Down
24 changes: 12 additions & 12 deletions src/MultiSelectModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,17 +363,17 @@ export class MultiSelectModal extends Modal {
private updateQuantityDisplay(labelText: string) {
const stock = this.boosters[labelText];
const stockInfo = this.containerEl.querySelector(`.${labelText.replace(' ', '-')}`);

if (stockInfo) {
// Clear the current content
stockInfo.empty();

// Create and set the new content
stockInfo.createEl('div', { text: `${labelText} : (${stock})` });
}

const buttonUse: HTMLButtonElement | null = this.containerEl.querySelector(`#use-button-${labelText.replace(' ', '-')}`);

if (buttonUse !== null) {
const momentDate = window.moment(this.mediator.getSettingString(this.getBoosterDateFromName(labelText)), 'YYYY-MM-DD HH:mm:ss');

Expand All @@ -385,7 +385,7 @@ export class MultiSelectModal extends Modal {
}
}
}



private checkIngredientsAvailability(incredients: { name: string; incredients: string[]; }) {
Expand All @@ -406,13 +406,13 @@ export class MultiSelectModal extends Modal {

private check1000IngredientsAvailableAndBurn() {
let totalAvailableIngredients = 0;

// Calculate the total number of available ingredients
//elements.forEach(increment => {
listOfUseableIngredientsToBeShown.forEach(increment => {
totalAvailableIngredients += this.remainingStock[this.getIngerementFromName(increment).name] || 0;
});

if(debugLogs) console.debug(`total amount of ingrediments: ${totalAvailableIngredients}`)
// If at least 1000 ingredients are available
if (totalAvailableIngredients >= 1000) {
Expand All @@ -428,20 +428,20 @@ export class MultiSelectModal extends Modal {
this.updateIncrementStock(this.getIngerementFromName(increment).name, this.remainingStock[this.getIngerementFromName(increment).name] - proportionalAmount)
}
});

//save new stock

// Update the stock information display
this.updateStockInformation();

return true;
}

return false;
}







private useIngrediments(incredients: { name: string; incredients: string[]; }) {
Expand Down
Loading

0 comments on commit 445d384

Please sign in to comment.