Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniopresto committed Feb 25, 2024
1 parent bd8c0dd commit da780ec
Show file tree
Hide file tree
Showing 45 changed files with 811 additions and 258 deletions.
8 changes: 4 additions & 4 deletions .idea/codeStyles/Project.xml

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

27 changes: 10 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"name": "powership",
"version": "3.2.16",
"version": "3.2.20",
"private": true,
"scripts": {
"pack": "run-s pack:*",
"pack:publish": "run \"pnpm publish\"",
"prepublishSafe": "bun-safe ./prepublishSafe.ts",
"pre": "run prepublishOnly",
"fix": "turbo run fix",
"test": "turbo run test",
"fix": "run fix",
"test": "run test",
"validate": "(cd packages/schema && npm run prepublish)",
"doc": "typedoc",
"i": "rm -rf node_modules/.pnpm && rm -rf pnpm-lock.yaml && pnpm install",
"reset": "./reset.sh",
"beta": "bun run scripts/beta.ts",
"beta-version": "bun run scripts/beta-version.ts"
},
"devDependencies": {
"dependencies": {
"@powership/babel-plugins": "workspace:*",
"@types/fs-extra": "9.0.13",
"@types/jest": "29.1.2",
Expand All @@ -42,9 +42,13 @@
"shelljs": "0.8.5",
"ts-jest": "29.0.3",
"ts-node": "10.9.1",
"turbo": "1.9.1",
"runmate": "latest",
"typedoc-plugin-markdown": "3.14.0",
"typescript": "4.8.2"
"typescript": "4.8.2",
"bun-safe": "1.0.5",
"semver": "7.5.2",
"typedoc": "0.23.24",
"zx": "7.2.3"
},
"xworkspaces": [
"@powership/accounts",
Expand All @@ -59,16 +63,5 @@
"@powership/schema",
"@powership/transporter"
],
"dependencies": {
"bun-safe": "1.0.5",
"semver": "7.5.2",
"typedoc": "0.23.24",
"zx": "7.2.3"
},
"workspaces": {
"packages": [
"packages/*"
]
},
"packageManager": "[email protected]"
}
2 changes: 1 addition & 1 deletion packages/accounts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powership/accounts",
"version": "3.2.16",
"version": "3.2.22",
"description": "Powership accounts",
"type": "module",
"main": "./out/index.cjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugins/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powership/babel-plugins",
"version": "3.2.16",
"version": "3.2.22",
"main": "./out/index.js",
"sideEffects": false,
"typings": "./out/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { PluginObj } from '@babel/core';

/**
* Plugin to transform lodash imports to ESM format.
* @returns {PluginObj} The Babel plugin object.
*/
export function TransformLodashImportsPlugin(): PluginObj {
return {
name: 'transform-lodash-imports',

visitor: {
ImportDeclaration(path) {
const lodashPattern = /^(lodash)(\/.*)?$/;
const sourceValue = path.node.source.value;

if (lodashPattern.test(sourceValue)) {
// If it's a lodash import, modify it to use an ESM format.
path.node.source.value = sourceValue.replace(
lodashPattern,
(_match, _lodash, subPath) => {
// If there's a subpath (like lodash/map), format it for ESM.
// Otherwise, return 'lodash-es'.
return subPath ? `lodash-es${subPath}` : 'lodash-es';
}
);
}
},
},
};
}
1 change: 1 addition & 0 deletions packages/babel-plugins/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './strip-blocks';
export * from './module-extensions';
export * from './babel-transform-lodash-imports-plugin';
10 changes: 7 additions & 3 deletions packages/boilerplate/babel-config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ModuleExtensions } = require('@powership/babel-plugins');
const { ModuleExtensions, StripBlocksPlugin, TransformLodashImportsPlugin } = require('@powership/babel-plugins');
const { TARGET } = process.env;
const validTargets = ['module', 'browser', 'node', 'module-browser', 'module-node'];

Expand Down Expand Up @@ -71,19 +71,23 @@ module.exports = function (api) {
const plugins = [
['babel-plugin-add-import-extension', { extension: destinationExtension, replace: true }],
[
require('@powership/babel-plugins').StripBlocksPlugin,
StripBlocksPlugin,
{
magicComment: `@only-${KIND_INVERT}`,
},
],
[
require('@powership/babel-plugins').ModuleExtensions,
ModuleExtensions,
{
destinationExtension,
},
],
];

if (destinationExtension === 'mjs') {
plugins.unshift([TransformLodashImportsPlugin, {}]);
}

return {
presets,
plugins,
Expand Down
2 changes: 1 addition & 1 deletion packages/boilerplate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powership/boilerplate",
"version": "3.2.16",
"version": "3.2.22",
"author": "antoniopresto <[email protected]>",
"sideEffects": false,
"type": "module",
Expand Down
3 changes: 2 additions & 1 deletion packages/deepstate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powership/deepstate",
"version": "3.2.16",
"version": "3.2.22",
"main": "out/index.cjs",
"module": "out/module/index.mjs",
"sideEffects": false,
Expand Down Expand Up @@ -47,6 +47,7 @@
"@types/jest": "29.5.3",
"@types/json-schema": "7.0.11",
"@types/lodash": "4.14.191",
"@types/lodash-es": "4.17.12",
"@types/node": "16.18.3",
"@types/supertest": "2.0.12",
"@typescript-eslint/eslint-plugin": "5.39.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/entity/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powership/entity",
"version": "3.2.16",
"version": "3.2.22",
"type": "module",
"main": "./out/index.cjs",
"module": "./out/module/index.mjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/helpers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powership/helpers",
"version": "3.2.16",
"version": "3.2.22",
"type": "module",
"main": "./out/index.cjs",
"module": "./out/module/index.mjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/logstorm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "logstorm",
"version": "3.2.16",
"version": "3.2.22",
"typings": "out",
"author": "antoniopresto <[email protected]>",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/mongo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powership/mongo",
"version": "3.2.16",
"version": "3.2.22",
"type": "module",
"main": "./out/index.cjs",
"module": "./out/module/index.mjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plugin-engine",
"version": "3.2.16",
"version": "3.2.22",
"type": "module",
"main": "./out/index.cjs",
"module": "./out/module/index.mjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/powership/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "powership",
"version": "3.2.16",
"version": "3.2.22",
"author": "antoniopresto <[email protected]>",
"type": "module",
"main": "./out/index.cjs",
Expand Down
5 changes: 4 additions & 1 deletion packages/runmate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "runmate",
"version": "3.2.18",
"version": "3.2.22",
"typings": "out",
"author": "antoniopresto <[email protected]>",
"license": "MIT",
Expand Down Expand Up @@ -43,14 +43,17 @@
"dependencies": {
"@types/glob": "^8.1.0",
"@types/lodash": "4.14.191",
"@types/lodash-es": "4.17.12",
"@types/semver": "7.3.13",
"@types/vorpal": "1.12.2",
"chalk": "4.1.2",
"commander": "10.0.0",
"fs-extra": "10.1.0",
"glob": "8.1.0",
"lodash": "4.17.21",
"lodash-es": "4.17.21",
"logstorm": "workspace:*",
"@powership/utils": "workspace:*",
"plugin-hooks": "2.0.0",
"semver": "7.5.2",
"tsx": "^3.14.0"
Expand Down
14 changes: 8 additions & 6 deletions packages/runmate/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Command } from 'commander';
import { align } from './commands/align';
import { list } from './commands/list';
import { main } from './commands/main';
import { setJsonValue } from './commands/set-json-value';
import { version } from './commands/version';
import { packageRunner, PackageRunnerUtils } from './packageRunner';
import { packageJSONDependencyKeys } from './packageVersion';
Expand All @@ -23,9 +24,9 @@ program
'Chunk size of parallel executions',
'10'
)
.option('-s, --src <pattern>', 'Folder pattern')
.option('-d, --cwd <pattern>', 'Folder pattern')
.action(async function run(options): Promise<any> {
const { chunkSize, src } = options || {};
const { chunkSize, cwd: src } = options || {};

try {
const runner = await packageRunner(src);
Expand All @@ -42,15 +43,15 @@ program
.command('each')
.alias('packages')
.argument('[command...]')
.option('-s, --src <pattern>', 'Folder pattern')
.option('-d, --cwd <pattern>', 'Folder pattern')
.option(
'-c, --chunk-size <chunk-size>',
'Chunk size of parallel executions',
'1'
)
.alias('e')
.action(async function run(commands: string[], options): Promise<any> {
const { chunkSize, src } = options;
const { chunkSize, cwd: src } = options;
const command = commands.join(' ');

try {
Expand All @@ -69,7 +70,7 @@ program
.description(
'Executes `link` or any other command in every dependency/dependent package.'
)
.option('-s, --src <pattern>', 'Packages glob pattern.')
.option('-d, --cwd <pattern>', 'Packages glob pattern.')
.option('--clean', 'Clean node_modules before link.')
.option('-c, --chunkSize <value>', 'Parallel executions size.', '10')
.alias('l')
Expand All @@ -78,7 +79,7 @@ program
'Run command only in specified package and after in the dependency tree.'
)
.action(async function run(options): Promise<any> {
const { src, chunkSize = 10, clean, from } = options || {};
const { cwd: src, chunkSize = 10, clean, from } = options || {};

const localPackages = new Map<string, PackageRunnerUtils>();

Expand Down Expand Up @@ -140,6 +141,7 @@ program
list(program);
version(program);
align(program);
setJsonValue(program);

program.version('> Runmate ' + require('../package.json').version);

Expand Down
8 changes: 4 additions & 4 deletions packages/runmate/src/commands/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export function main(program: Command) {
.command('packages', { isDefault: true })
.argument('<command...>')
.description(
'Run command in each package in ./packages folder or in `--src` option folder'
'Run command in each package in ./packages folder or in `--cwd` option folder'
)
.option('-s, --src <pattern>', 'Source directory or glob pattern')
.option('-d, --cwd <pattern>', 'Source directory or glob pattern')
.option(
'-c, --chunk-size <number>',
'Chunk size of parallel executions',
Expand All @@ -33,7 +33,7 @@ export function main(program: Command) {
.action(async function run(
commands: string[],
options?: {
src?: string;
cwd?: string;
chunkSize: string;
failFast: boolean;
ignore?: string;
Expand All @@ -44,7 +44,7 @@ export function main(program: Command) {
): Promise<any> {
const {
//
src,
cwd: src,
chunkSize = 1,
failFast,
ignore,
Expand Down
Loading

0 comments on commit da780ec

Please sign in to comment.