Skip to content

Commit

Permalink
Port to ESM (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
win0err authored Aug 21, 2023
1 parent 0d3a21b commit 324af76
Show file tree
Hide file tree
Showing 26 changed files with 545 additions and 467 deletions.
72 changes: 33 additions & 39 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
{
"env": {
"es2021": true
},
"extends": "airbnb/base",
"parserOptions": {
"ecmaVersion": "latest"
},
"ignorePatterns": ["@types/", "node_modules/"],
"rules": {
"indent": [
"error",
4
],
"arrow-parens": ["error", "as-needed"],
"no-underscore-dangle": [
"error",
{
"allowAfterThis": true,
"allowAfterSuper": true
}
],
"no-unused-vars": [
"error",
{
"varsIgnorePattern": "^(init|enable|disable|buildPrefsWidget)$"
}
],
"eol-last": ["error", "never"],
"strict": "off",
"no-plusplus": "off",
"max-len": [
"error",
120
]
},
"globals": {
"imports": "readonly",
"log": "readonly"
}
"env": { "es2021": true },
"plugins": ["import"],
"extends": ["eslint:recommended"],
"parserOptions": {
"ecmaVersion": 2022,
"sourceType": "module"
},
"ignorePatterns": ["@types/", "node_modules/"],
"rules": {
"quotes": ["error", "single"],
"no-tabs": "off",
"indent": ["error", "tab"],
"semi": ["error", "never"],
"arrow-parens": ["error", "as-needed", { "requireForBlockBody": true }],
"no-trailing-spaces": "error",
"comma-dangle": ["error", "always-multiline"],
"newline-before-return": "error",
"no-underscore-dangle": ["error", { "allowAfterThis": true, "allowAfterSuper": true }],
"no-unused-vars": "error",
"eol-last": ["error", "always"],
"strict": "off",
"no-plusplus": "off",
"max-len": ["error", 120],
"import/extensions": 0,
"import/newline-after-import": ["error", { "count": 2 }],
"import/no-unresolved": [2, { "ignore": ["^(resource|gi)"] }],
"no-warning-comments": ["error", { "terms": ["fixme"], "location": "anywhere" }]
},
"globals": {
"log": "readonly",
"logError": "readonly",
"TextDecoder": "readonly"
}
}
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
with:
node-version: '18'
- name: Lint code
run: npm install && npm run lint
run: npm install && npm run test:lint
- name: Check that the translation files have been updated
run: |
make --always-make translations
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ yarn.lock
package-lock.json
docs-lock.json
src/schemas/gschemas.compiled
po/*~
po/*~
tsconfig.alias.json
.#*
28 changes: 7 additions & 21 deletions .ts-for-girrc.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
{
"environments": [
"gjs"
],
"modules": [
"Gtk-4.0",
"Gtk-3.0",
"Soup-2.4",
"Shell-0.1",
"St-1.0",
"Adw-1",
"Clutter-10",
"Meta-10"
],
"prettify": true,
"girDirectories": [
"/usr/share/gir-1.0",
"/usr/share/gnome-shell",
"/usr/lib64/mutter-10/"
],
"outdir": "node_modules/@types"
}
"environments": ["gjs"],
"ignoreVersionConflicts": true,
"buildType": "types",
"generateAlias": true,
"prettify": true,
"outdir": "./@types"
}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ all_sources = $(shell find src -type f)

js_sources = $(shell cd src && find . -maxdepth 1 -type f -name '*.js')

translations_sources = src/panelMenuButton.js src/prefs.js
translations_sources = src/indicator.js src/prefs.js
translations_sources += $(shell find src/resources/ui -maxdepth 1 -type f -name '*.ui')
translations = $(shell find po -maxdepth 1 -type f -name '*.po')

Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ $ gnome-extensions install path/to/[email protected] --fo

#### After installation:
1. Restart the GNOME Shell:
- <kbd>ALT</kbd>+<kbd>F2</kbd> to open the command prompt, and enter <kbd>r</kbd> to restart the GNOME Shell;
- <kbd>ALT</kbd>+<kbd>F2</kbd> to open the command prompt, and enter <kbd>r</kbd> to restart the GNOME Shell (available on Xorg only);
- or Log Out, then Log In, if GNOME Shell won't restart;
2. Enable the extension:
- Open GNOME Tweaks → Extensions → RunCat → On;
- Open GNOME Extensions → RunCat → On;
- or Run in terminal: `gnome-extensions enable [email protected]`.


### Manage RunCat preferences
- Right-click on the extension button on the top bar → Settings;
- or Open GNOME Tweaks → Extensions → RunCat → ⚙️;
- or Open GNOME Extensions → RunCat → ⚙️;
- or Open [RunCat on GNOME Extensions portal](https://extensions.gnome.org/extension/2986/runcat/) → ⚙️;
- or Manage directly in `dconf`: `dconf list /org/gnome/shell/extensions/runcat/`.

Expand All @@ -64,6 +64,13 @@ To create a new translation file, use the following command: \
**Spanish** locale: `msginit -i po/messages.pot -l es --no-translator -o po/es.po`. \
**Spanish (Argentina)** locale: `msginit -i po/messages.pot -l es_AR --no-translator -o po/es_AR.po`.

### Useful commands for developers

You need to install project JS dependencies first: `npm i`

- `npm run types:generate` — generate type definition for GJS environment;
- `npm run test:lint` — lint project files.

## macOS version
Thanks to [Takuto Nakamura](https://github.com/Kyome22/menubar_runcat) for [the macOS version](https://kyome.io/runcat/index.html) and cat images.

Expand Down
26 changes: 26 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"target": "ES2022",
"allowJs": true,
"noEmit": true,
"skipLibCheck": true,
"module": "ES2022",
"baseUrl": ".",
"paths": {
"gi://Adw": ["@types/adw-1.d.ts"],
"gi://Gtk": ["@types/gtk-4.0.d.ts"],
"gi://GLib": ["@types/glib-2.0.d.ts"],
"gi://Gio": ["@types/gio-2.0.d.ts"],
"gi://Shell": ["@types/shell-12.d.ts"],
"gi://St": ["@types/st-12.d.ts"],
"gi://Gdk": ["@types/gdk-4.0.d.ts"],
"gi://GObject": ["@types/gobject-2.0.d.ts"]
},
"rootDirs": ["src"]
},
"include": [
"src/**/*",
"@types/gjs.d.ts",
"@types/dom.d.ts"
]
}
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
"name": "runcat",
"private": true,
"scripts": {
"generate:types": "ts-for-gir generate --configName=.ts-for-girrc.json --ignoreVersionConflicts",
"lint": "eslint src/"
"types:generate": "ts-for-gir generate --configName=.ts-for-girrc.json",
"test:lint": "eslint src/"
},
"repository": "win0err/gnome-runcat",
"author": "Sergei Kolesnikov <[email protected]>",
"license": "GPL-3.0",
"devDependencies": {
"@ts-for-gir/cli": "^3.0.0-beta.2",
"eslint": "^8.24.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.26.0"
"@ts-for-gir/cli": "^3.2.0",
"eslint": "^8.47.0",
"eslint-plugin-import": "^2.28.0",
"eslint-import-resolver-typescript": "^3.6.0"
}
}
12 changes: 6 additions & 6 deletions po/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: gnome-runcat-extension 23\n"
"Project-Id-Version: gnome-runcat-extension 24\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-03-26 17:49+0300\n"
"POT-Creation-Date: 2023-08-21 11:27+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -17,19 +17,19 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: src/panelMenuButton.js:95
#: src/indicator.js:160
msgid "Open System Monitor"
msgstr ""

#: src/panelMenuButton.js:99
#: src/indicator.js:164
msgid "Settings"
msgstr ""

#: src/prefs.js:48
#: src/prefs.js:54
msgid "RunCat Settings"
msgstr ""

#: src/prefs.js:59
#: src/prefs.js:98
msgid "Version"
msgstr ""

Expand Down
12 changes: 6 additions & 6 deletions po/ru.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: gnome-runcat-extension 20\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-10-05 02:43+0300\n"
"POT-Creation-Date: 2023-08-21 11:13+0300\n"
"PO-Revision-Date: 2022-09-30 19:16+0300\n"
"Last-Translator: Sergei Kolesnikov <[email protected]>\n"
"Language-Team: Russian\n"
Expand All @@ -18,19 +18,19 @@ msgstr ""
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"

#: src/panelMenuButton.js:95
#: src/indicator.js:160
msgid "Open System Monitor"
msgstr "Открыть Системный монитор"

#: src/panelMenuButton.js:99
#: src/indicator.js:164
msgid "Settings"
msgstr "Настройки"

#: src/prefs.js:48
#: src/prefs.js:54
msgid "RunCat Settings"
msgstr "Настройки RunCat"

#: src/prefs.js:59
#: src/prefs.js:98
msgid "Version"
msgstr "Версия"

Expand Down Expand Up @@ -72,7 +72,7 @@ msgstr "Сбросить настройки RunCat к значениям по у

#: src/resources/ui/preferences.ui:65
msgid "Reset"
msgstr "Сбрость"
msgstr "Сбросить"

#: src/resources/ui/preferences.ui:84
msgid "The cat tells you the CPU usage by running speed"
Expand Down
32 changes: 15 additions & 17 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
/* eslint-disable no-var, no-unused-vars */
export const LOG_PREFIX = 'RuncatExtension'
export const LOG_ERROR_PREFIX = 'RuncatExtensionError'

var SCHEMA_PATH = 'org.gnome.shell.extensions.runcat';
var LOG_ERROR_PREFIX = 'RuncatExtensionError';
const CHARACTER_AND_PERCENTAGE = 0
const PERCENTAGE_ONLY = 1
const CHARACTER_ONLY = 2

const CHARACTER_AND_PERCENTAGE = 0;
const PERCENTAGE_ONLY = 1;
const CHARACTER_ONLY = 2;
export const displayingItems = {
[CHARACTER_AND_PERCENTAGE]: { character: true, percentage: true },
[PERCENTAGE_ONLY]: { character: false, percentage: true },
[CHARACTER_ONLY]: { character: true, percentage: false },
}

var PanelMenuButtonVisibility = {
[CHARACTER_AND_PERCENTAGE]: { character: true, percentage: true },
[PERCENTAGE_ONLY]: { character: false, percentage: true },
[CHARACTER_ONLY]: { character: true, percentage: false },
};
export const gioSettingsKeys = {
IDLE_THRESHOLD: 'idle-threshold',
DISPLAYING_ITEMS: 'displaying-items',
}

var Settings = {
IDLE_THRESHOLD: 'idle-threshold',
DISPLAYING_ITEMS: 'displaying-items',
};

var SYSTEM_MONITOR_COMMAND = 'gnome-system-monitor -r';
export const SYSTEM_MONITOR_COMMAND = 'gnome-system-monitor -r'
Loading

0 comments on commit 324af76

Please sign in to comment.