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

Convert to ESM #123

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bb3cf2f
checkpoint: partial implentation of esm
begin-again Apr 23, 2024
7aefdb8
temp
begin-again Apr 23, 2024
7bb523e
replace temp module with temp class
begin-again Apr 23, 2024
4a6c5ed
common/repos: remove getBinaryPaths
begin-again Apr 24, 2024
6480c5d
common/engine: constructor tests
begin-again Apr 24, 2024
ac57ee2
progress
begin-again Apr 24, 2024
6af918d
more progress
begin-again Apr 24, 2024
2ffb4b1
remove old spec
begin-again Apr 24, 2024
775a5a2
update .mocha.yml to use js
begin-again Apr 24, 2024
a6f66a2
osType is a function
begin-again Apr 24, 2024
324f87f
rename yarn/index to js
begin-again Apr 24, 2024
2c2c52b
rename setup to js
begin-again Apr 24, 2024
076d9cb
engine: allInstalledNodeVersions test bug fix
begin-again Apr 24, 2024
df4babb
upgrades dependencies
begin-again Apr 24, 2024
d8f4806
fixed derfault param on versionToUseValidator
begin-again Apr 24, 2024
7cc7079
spawners: use process.stdout.write
begin-again Apr 24, 2024
1e36f06
add not about testing
begin-again Apr 24, 2024
9e2f3c7
commit changes to lock file
begin-again Apr 24, 2024
0281b6b
Update README.md
begin-again Jun 22, 2024
db5f265
Update src/common/net.js
begin-again Jun 22, 2024
98f495c
chore: Improve error handling in engines.js
begin-again Jun 22, 2024
e9fb1c8
chore: Refactor engine.js for better readability
begin-again Jun 22, 2024
9a677b0
split mocked FS by os
begin-again Jun 22, 2024
3e14075
ensure mocked fs is restored after tests
begin-again Jun 22, 2024
e27347c
misc changes
begin-again Jun 26, 2024
885a2b1
remove play
begin-again Jun 26, 2024
8a52718
remove package 'dev'
begin-again Jul 3, 2024
3da9ca4
fixes for type problems
begin-again Jul 3, 2024
3e371df
yarn upgrade to 4.3.1
begin-again Jul 6, 2024
d825bcc
linting fixes
begin-again Jul 9, 2024
9213d34
sync master
begin-again Jul 9, 2024
e747cc0
more lint/type fixes
begin-again Jul 9, 2024
8eb7269
sync master yet again
begin-again Jul 9, 2024
b2d2a8f
use v9 eslint
begin-again Jul 21, 2024
6030eea
add types for node and mocha; upgrade deps
begin-again Oct 5, 2024
430f7a0
refactor versionStringToNumber for readability
begin-again Oct 5, 2024
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
11 changes: 11 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

reviews:
path_instructions:
- path: "**/*.js"
instructions: |
Review the JavaScript code against the Google JavaScript style guide and point out any mismatches
- path: "test/**.*"
instructions: |
Review the following unit test code written using the Mocha test library. Ensure that:
- The code adheres to best practices associated with Mocha.
- Descriptive test names are used to clearly convey the intent of each test.
96 changes: 0 additions & 96 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

- name: Install ESLint
run: |
npm install eslint@8.56.0
npm install eslint@9.1.0
npm install @microsoft/[email protected]

- name: Run ESLint
Expand Down
894 changes: 894 additions & 0 deletions .yarn/releases/yarn-4.3.1.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ enableGlobalCache: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.3.0.cjs
yarnPath: .yarn/releases/yarn-4.3.1.cjs
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ Only works in Windows with Git For Windows installed. Not WSL.

## setup

Assumption is the all the local clones are in the same folder. For instance, I keep my work in a folder named _projects_ and every clone exists in that folder including this repository. There's a setup script which exits/creates one's bash_profile & bashrc files (with backup). The changes to bashrc are:
Assumption is the all the local clones are in the same folder. For instance, I keep my work in a folder named _projects_ and every clone exists in that folder including this repository. There's a setup script which exits/creates one's bash_profile & bashrc files (with backup). The changes to bashrc are:
begin-again marked this conversation as resolved.
Show resolved Hide resolved

1. Creation of a DEVROOT variable pointing to the parent folder where the repositories are kept.
1. Creation of a DEVROOT variable pointing to the parent folder where the repositories are kept.
2. A source command to load in this repository's `src/bash.sh`

## testing

The unit tests are required to be run with the latest node engine supported. Run `node src/misc/scripts.js` to obtain the nodejs engines in use.
begin-again marked this conversation as resolved.
Show resolved Hide resolved
102 changes: 102 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import pluginJs from '@eslint/js';
import globals from 'globals';
const IndentSpaces = 4;

export default [
pluginJs.configs.recommended
, {
files: [ '**/*.js' ]
, languageOptions: {
ecmaVersion: 2020
, globals: {
...globals.es2020
, ...globals.node
, ...globals.mocha
, console: true
, process: true
}
}
, linterOptions : {
noInlineConfig: false
}
, plugins: {
pluginJs
}
, rules: {
'array-bracket-spacing': [ 'error', 'always' ]
, 'arrow-spacing': [ 'error', { 'before': true, 'after': true } ]
, 'block-scoped-var': 'error'
, 'brace-style': [ 'error', 'stroustrup' ]
, 'camelcase': 'error'
, 'comma-spacing': [ 'error', { 'after': true } ]
, 'comma-style': [ 'error', 'first' ]
, 'curly': [ 'warn' ]
, 'default-case': 'error'
, 'dot-location': [ 'error', 'property' ]
, 'dot-notation': [ 'error' ]
, 'eqeqeq': [ 'error', 'smart' ]
, 'func-call-spacing': [ 'error', 'never' ]
, 'handle-callback-err': 'error'
, 'indent': [ 'error', IndentSpaces, { 'MemberExpression': 1, 'ArrayExpression': 1, 'ObjectExpression': 1 } ]
, 'keyword-spacing': [ 'error', { 'overrides': { 'if': { 'after': false }, 'for': { 'after': false }, 'while': { 'after': false } } } ]
, 'line-comment-position': [ 'error', { 'position': 'above' } ]
, 'newline-per-chained-call': [ 'error', { 'ignoreChainWithDepth': 2 } ]
, 'no-alert': [ 'error' ]
, 'no-caller': 'error'
, 'no-console': 'warn'
, 'no-div-regex': 'error'
, 'no-duplicate-imports': [ 'error', { includeExports: true } ]
, 'no-else-return': [ 'error', { allowElseIf: false } ]
, 'no-empty-function': 'error'
, 'no-eq-null': 'error'
, 'no-floating-decimal': 'error'
, 'no-implicit-coercion': [ 'error' ]
, 'no-irregular-whitespace': [ 'error', { skipComments: true } ]
, 'no-lone-blocks': [ 'error' ]
, 'no-lonely-if': 'error'
, 'no-magic-numbers': [ 'error', { ignore: [ 2, 1, 0, -1 ], ignoreArrayIndexes: true } ]
, 'no-multi-spaces': 'error'
, 'no-param-reassign': [ 'error', { props: false } ]
, 'no-path-concat': 'error'
, 'no-return-await': 'error'
, 'no-script-url': 'error'
, 'no-self-compare': [ 'error' ]
, 'no-tabs': 'error'
, 'no-trailing-spaces': 'error'
, 'no-unneeded-ternary': [ 'error' ]
, 'no-unsafe-negation': [ 'error' ]
, 'no-unused-vars': [ 'error', { args: 'all', caughtErrors: 'all' } ]
, 'no-useless-return': 'error'
, 'no-var': 'error'
, 'no-whitespace-before-property': 'error'
, 'object-curly-spacing': [ 'error', 'always' ]
, 'one-var': [ 'error', { var: 'always', let: 'never', const: 'never' } ]
, 'prefer-const': 'error'
, 'prefer-destructuring': [
'error'
, {
VariableDeclarator: {
array: false
, object: true,
}
, AssignmentExpression: {
array: true
, object: false,
},
}
, {
enforceForRenamedProperties: false,
}
, ]
, 'prefer-template': 'error'
, quotes: [ 'error', 'single', { allowTemplateLiterals: true } ]
, semi: [ 'error', 'always', { omitLastInOneLineBlock: true } ]
, 'space-before-blocks': [ 'error', 'always' ]
, 'space-in-parens': [ 'error', 'never' ]
, 'space-infix-ops': [ 'error' ]
, 'space-unary-ops': [ 'error', { words: true, nonwords: false } ]
, 'spaced-comment': [ 'error', 'always' ]
, yoda: 'error'
}
}
];
4 changes: 2 additions & 2 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"compilerOptions": {
"module": "commonjs",
"module": "NodeNext",
"target": "esnext",
"checkJs": true
"checkJs": true,
},
"include": [
"src/**/*.js",
Expand Down
27 changes: 16 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "my-dev-tools",
"version": "4.0.0",
"version": "5.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

CHANGELOG.md is missing for version 5.0.0

Please add a CHANGELOG.md file that includes an entry for version 5.0.0 to document the breaking changes introduced by converting the project to ESM.

🔗 Analysis chain

Version bump to 5.0.0 is appropriate.

The major version increment from 4.0.0 to 5.0.0 aligns with the significant change of converting the project to ESM. This follows semantic versioning principles.

Could you please ensure that a CHANGELOG.md file is updated to reflect the breaking changes introduced in this version? Run the following command to check:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if CHANGELOG.md exists and contains version 5.0.0
if [ -f CHANGELOG.md ]; then
    if grep -q "## \[5.0.0\]" CHANGELOG.md; then
        echo "CHANGELOG.md exists and contains version 5.0.0"
    else
        echo "CHANGELOG.md exists but does not contain version 5.0.0"
    fi
else
    echo "CHANGELOG.md does not exist"
fi

Length of output: 90

"main": "",
"type": "module",
"repository": "https://github.com/begin-again/dev-tools.git",
"license": "MIT",
"private": true,
Expand All @@ -15,24 +16,28 @@
},
"dependencies": {
"dotenv": "^16.4.5",
"luxon": "^3.4.4",
"semver": "^7.6.2",
"luxon": "^3.5.0",
"semver": "^7.6.3",
"shelljs": "^0.8.5",
"simple-git": "^3.25.0",
"simple-git": "^3.27.0",
"uuid": "10.0.0",
"yargs": "^17.7.2"
},
"devDependencies": {
"chai": "^4.4.1",
"eslint": "^8.56.0",
"@eslint/js": "^9.12.0",
"@types/mocha": "^10.0.8",
"@types/node": "^22.7.4",
"chai": "^4.5.0",
"eslint": "^9.12.0",
"eslint-plugin-node": "^11.1.0",
"mocha": "10",
"mock-fs": "^5.2.0",
"nyc": "^17.0.0",
"globals": "^15.10.0",
"mocha": "^10.7.3",
"mock-fs": "^5.3.0",
"nyc": "^17.1.0",
"proxyquire": "^2.1.3",
"randomatic": "^3.1.1",
"sinon": "^18.0.0",
"sinon": "^18.0.1",
"sinon-chai": "^3.7.0"
},
"packageManager": "[email protected].0"
"packageManager": "[email protected].1"
}
8 changes: 4 additions & 4 deletions src/branches/branches.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { basename } = require('path');
const { options } = require('./cmdline');
const { currentBranch, currentHash, commitDiffCounts, isDirty } = require('../common/git');
import { basename } from 'node:path';
import { options } from './cmdline.js';
import { currentBranch, currentHash, commitDiffCounts, isDirty } from '../common/git.js';
const hashLength = 7;

/**
Expand Down Expand Up @@ -68,7 +68,7 @@ const branches = (repoPath) => {
});
};

module.exports = {
export {
branches
, report
};
21 changes: 10 additions & 11 deletions src/branches/cmdline.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

const yargs = require('yargs');
const { constants, accessSync, lstatSync } = require('fs');
import { constants, accessSync, lstatSync } from 'node:fs';
import yargs from 'yargs/yargs';

const cmdKeys = {
'folder-names': {
Expand All @@ -13,7 +12,7 @@ const cmdKeys = {
alias: 'r'
, describe: 'over ride the value in $DEVROOT'
, type: 'string'
// eslint-disable-next-line no-process-env

, default: process.env.DEVROOT
}
, 'fetch': {
Expand Down Expand Up @@ -71,7 +70,7 @@ const validateNoConflict = ({ folderNames, deploy }) => {
const options = {};

const setOptions = (test) => {
const argv = test || yargs
const argv = test || yargs(process.argv.slice(2))
.options(cmdKeys)
.help(true)
.version(false)
Expand All @@ -85,14 +84,14 @@ const setOptions = (test) => {
.check(validateNoConflict)
.argv;

module.exports.options.root = argv.root;
module.exports.options.folderNames = argv.folderNames || [];
module.exports.options.fetch = argv.fetch;
module.exports.options.silent = argv.silent;
module.exports.options.deploy = argv.deploy;
options.root = argv.root;
options.folderNames = argv.folderNames || [];
options.fetch = argv.fetch;
options.silent = argv.silent;
options.deploy = argv.deploy;
};

module.exports = {
export {
options
, setOptions
};
Loading