Skip to content
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

Publish for mobile and Refactoring unit test #56

Merged
merged 21 commits into from
Dec 22, 2023
Merged
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
20 changes: 1 addition & 19 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,9 @@ main.js
data.json

# Exclude macOS Finder (System Explorer) View States
coverage/
.DS_Store
/cp-js2cortex.bat
ncryption
data_bkp_231023.json

# Ignore Test Data
*.html
*.xml
coverage/lcov.info
coverage/lcov-report/badges.ts.html
coverage/lcov-report/constants.ts.html
coverage/lcov-report/creatmodchartcalculation.ts.html
coverage/lcov-report/index.html
coverage/lcov-report/levels.ts.html
coverage/lcov-report/main.ts.html
coverage/lcov-report/majuritycalculation.ts.html
coverage/lcov-report/randomNotificationText.ts.html
coverage/lcov-report/utils.ts.html
coverage/clover.xml
coverage/coverage-final.json
coverage/lcov-report/encryption.ts.html
coverage/lcov-report/ModalBooster.ts.html
coverage/lcov-report/ModalInformationbox.ts.html
coverage/lcov-report/MultiSelectModal.ts.html
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ In some cases the same vault is used vor other activities as well an the knowled

### initialise game

When not already done during installation, hit `CTRL+P` and run command `Initialize gamification ratings`. This command will create you profile, rate you existing notes and give you a starting level. On the profile you can get informations to you current level, points, badges and see the distribution of you note maturitys.
When not already done during installation, hit `CTRL+P` and run command `Initialize gamification ratings`. This command will create you profile, rate you existing notes and give you a starting level. On the profile you can get informations to you current level, points, badges and see the distribution of you note maturitys.

![Gamification Initialization Command](/docs/images/GamificationInitializationCommand.png)

Expand Down
19 changes: 11 additions & 8 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
collectCoverage: true,
preset: 'ts-jest',
testEnvironment: 'node',
moduleNameMapper: {
'^obsidian$': 'obsidian',
},
collectCoverage: true,
collectCoverageFrom: ["./src/**"],
coverageThreshold: {
"global": {
"lines": 4
}},
};
global: {
lines: 4,
},
},
};
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"id": "gamified-pkm",
"name": "Gamificate your PKM",
"version": "0.0.85",
"version": "0.0.86",
"minAppVersion": "0.15.0",
"description": "Enhance your Personal Knowledge Management with gamification elements. Boost motivation and achieve growth as you engage with your PKM.",
"author": "Andreas Trebing",
"authorUrl": "https://github.com/saertna",
"fundingUrl": "https://ko-fi.com/andreastrebing",
"isDesktopOnly": true
"isDesktopOnly": false
}
Binary file modified obsidian-gamified-pkm/obsidian-gamified-pkm.zip
Binary file not shown.
18 changes: 9 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-gamified-pkm",
"version": "0.0.85",
"version": "0.0.86",
"description": "Enhance your Personal Knowledge Management with gamification elements. Boost motivation and achieve growth as you engage with your PKM.",
"main": "main.js",
"scripts": {
Expand Down Expand Up @@ -29,7 +29,7 @@
"jest-mock-extended": "^3.0.5",
"lint": "^1.1.2",
"markdownlint": "^0.30.0",
"obsidian": "^1.3.5",
"obsidian": "^1.4.11",
"ts-jest": "^29.1.1",
"tslib": "2.4.0",
"typescript": "4.7.4"
Expand Down
22 changes: 22 additions & 0 deletions preprelease.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import shutil
import zipfile
import subprocess
from urllib.parse import urlparse


Expand Down Expand Up @@ -66,11 +67,22 @@ def update_json_version(file_path, new_version):
# arcname = os.path.relpath(file_path, source_folder)
# zip_file.write(file_path, arcname=arcname)

def update_constants(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 main(new_version):
plugin_folder = '.'
readme_path = os.path.join(plugin_folder, 'README.md')
manifest_path = os.path.join(plugin_folder, 'manifest.json')
package_path = os.path.join(plugin_folder, 'package.json')
constants_path = os.path.join(plugin_folder, 'src', 'constants.ts')


# Update README.md
update_readme_version(readme_path, new_version)
Expand All @@ -80,6 +92,16 @@ def main(new_version):

# Update package.json
update_json_version(package_path, new_version)

# Update constants.ts
update_constants(constants_path)

# Run npm build commands
try:
subprocess.run(["npm", "install"], check=True, cwd=plugin_folder, shell=True)
subprocess.run(["npm", "run", "build"], check=True, cwd=plugin_folder, shell=True)
except subprocess.CalledProcessError as e:
print(f"Error running npm commands: {e}")

# Zip files
files_to_zip = ['main.js', 'manifest.json', 'styles.css']
Expand Down
11 changes: 8 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import {
rateNoteLength,
rateOutlinks,
rateProgressiveSummarization
} from './majuritycalculation'
import {Badge, checkIfReceiveABadge, getBadgeForInitLevel, getBadgeForLevel, getBadgeDetails, getBadge} from './badges'
} from './maturitycalculation'
import {Badge, checkIfReceiveABadge, getBadgeForInitLevel, getBadgeForLevel , getBadgeDetails , getBadge } from './badges'
import {getLevelForPoints, statusPointsForLevel} from './levels'
import type {Moment} from 'moment';
import {
Expand Down Expand Up @@ -464,7 +464,12 @@ export default class gamification extends Plugin {
// get file content length
const activeView = this.app.workspace.getActiveViewOfType(MarkdownView);
const fileContents = activeView?.editor.getValue();
const fileName = activeView?.file.basename;
//const fileName = activeView?.file.basename;
const fileName = activeView?.file?.basename;
if (fileName === null || fileName === undefined) {
console.error("File name is null or undefined. Stopping further processing.");
return;
}


let rateFileLength = 0;
Expand Down
Loading