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

feat: union generators and utils package #2289

Closed
wants to merge 5 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
plugins: ['node'],
settings: {
node: {
allowModules: ['@webpack-cli/generators', '@webpack-cli/utils'],
allowModules: ['@webpack-cli/generators'],
},
},
env: {
Expand Down
4 changes: 2 additions & 2 deletions packages/generators/__tests__/utils/languageSupport.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import language, { LangType, getBabelLoader, getTypescriptLoader } from '../../lib/utils/languageSupport';
import { CustomGenerator } from '../../lib/types';
import language, { LangType, getBabelLoader, getTypescriptLoader } from '../../src/utils/languageSupport';
import { CustomGenerator } from '../../src/types';

describe('languageSupport', () => {
const getMockGenerator = (): CustomGenerator => {
Expand Down
2 changes: 1 addition & 1 deletion packages/generators/__tests__/utils/plugins.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { replaceAt, generatePluginName } from '../../lib/utils/plugins';
import { replaceAt, generatePluginName } from '../../src/utils/plugins';

describe('generate plugin name', () => {
it('should return webpack Standard Plugin Name for Name : extract-text-webpack-plugin', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/generators/__tests__/utils/styleSupport.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import style, { StylingType } from '../../lib/utils/styleSupport';
import { CustomGenerator } from '../../lib/types';
import style, { StylingType } from '../../src/utils/styleSupport';
import { CustomGenerator } from '../../src/types';

describe('styleSupport', () => {
const getMockGenerator = (): CustomGenerator => {
Expand Down
18 changes: 15 additions & 3 deletions packages/generators/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@
"plugin-template"
],
"dependencies": {
"@webpack-cli/utils": "^1.2.1",
"colorette": "^1.2.1",
"log-symbols": "^4.0.0",
"yeoman-environment": "^2.10.3",
"yeoman-generator": "^4.12.0"
"yeoman-generator": "^4.12.0",
"execa": "^4.1.0",
"findup-sync": "^4.0.0",
"global-modules": "^2.0.0",
"got": "^11.8.0",
"jscodeshift": "^0.11.0",
"p-each-series": "^2.1.0"
},
"peerDependencies": {
"webpack": "4.x.x || 5.x.x",
Expand All @@ -33,7 +38,14 @@
"@types/yeoman-test": "^2.0.5",
"rimraf": "^3.0.2",
"yeoman-assert": "^3.1.1",
"yeoman-test": "^2.3.0"
"yeoman-test": "^2.3.0",
"@types/got": "^9.6.11",
"@types/prettier": "^2.1.5"
},
"peerDependenciesMeta": {
"prettier": {
"optional": true
}
},
"gitHead": "fb50f766851f500ca12867a2aa9de81fa6e368f9"
}
2 changes: 1 addition & 1 deletion packages/generators/src/addon-generator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs';
import path from 'path';
import Generator from 'yeoman-generator';
import { generatorCopy, generatorCopyTpl } from '@webpack-cli/utils';
import { generatorCopy, generatorCopyTpl } from '.';

import { utils } from 'webpack-cli';

Expand Down
13 changes: 13 additions & 0 deletions packages/generators/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,16 @@ class GeneratorsCommand {

export default GeneratorsCommand;
export { addonGenerator, initGenerator };

export * from './utils/ast-utils';
export * from './utils/copy-utils';
export * from './utils/modify-config-helper';
export * from './utils/npm-exists';
export * from './utils/npm-packages-exists';
export * from './utils/recursive-parser';
export * from './utils/resolve-packages';
export * from './utils/run-prettier';
export * from './utils/scaffold';
export * from './utils/validate-identifier';
export * from './utils/prop-types';
export * from './utils/global-packages-path';
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import {
getRequire,
safeTraverse,
safeTraverseAndGetType,
} from '../src/ast-utils';
import { Node } from '../src/types/NodePath';
} from '../ast-utils';
import { Node } from '../types/NodePath';

describe('utils', () => {
describe('createProperty', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// eslint-disable-next-line node/no-unpublished-import
import { findProjectRoot } from '../../../src/path-utils';
import { findProjectRoot } from '../../../path-utils';
import { join } from 'path';

beforeAll(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
jest.setMock('webpack-cli/lib/utils/get-package-manager', jest.fn());

import { getPathToGlobalPackages } from '../lib/global-packages-path';
import { getPathToGlobalPackages } from '../global-packages-path';
import { utils } from 'webpack-cli';

const { getPackageManager } = utils;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import path from 'path';
import { isLocalPath } from '../src/path-utils';
import { isLocalPath } from '../path-utils';

describe('is-local-path', () => {
it('returns true for paths beginning in the current directory', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
import { npmExists } from '../src/npm-exists';
import { npmExists } from '../npm-exists';

describe('npm-exists', () => {
it('should successfully existence of a published module', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { npmPackagesExists } from '../src/npm-packages-exists';
import { resolvePackages } from '../src/resolve-packages';
import { npmPackagesExists } from '../npm-packages-exists';
import { resolvePackages } from '../resolve-packages';

jest.mock('../src/npm-exists');
jest.mock('../src/resolve-packages');
jest.mock('../npm-exists');
jest.mock('../resolve-packages');

// TS is not aware that jest changes the type of resolvePackages
const mockResolvePackages = resolvePackages as jest.Mock<typeof resolvePackages>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ exports[`recursive parser remove transforms correctly using "fixture-3" data 1`]
symlinks: true
},
module: {
noParse: function(content) {
noParse: function (content) {
return /jquery|lodash/.test(content);
},
rules: [
Expand Down Expand Up @@ -167,7 +167,7 @@ exports[`recursive parser remove transforms correctly using "fixture-3" data 2`]
symlinks: true,
},
module: {
noParse: function(content) {
noParse: function (content) {
return /jquery|lodash/.test(content);
},
rules: [
Expand Down Expand Up @@ -287,7 +287,7 @@ exports[`recursive parser remove transforms correctly using "fixture-3" data 4`]
symlinks: true,
},
module: {
noParse: function(content) {
noParse: function (content) {
return /jquery|lodash/.test(content);
},
rules: [
Expand Down Expand Up @@ -349,7 +349,7 @@ exports[`recursive parser remove transforms correctly using "fixture-3" data 5`]
symlinks: true,
},
module: {
noParse: function(content) {
noParse: function (content) {
return /jquery|lodash/.test(content);
},
rules: [{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = {
symlinks: true,
},
module: {
noParse: function(content) {
noParse: function (content) {
return /jquery|lodash/.test(content);
},
rules: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import { join } from 'path';
import defineTest from '../defineTest';
import defineTest from '../../defineTest';

describe('recursive parser', () => {
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fs from 'fs';
import path from 'path';
//eslint-disable-next-line node/no-extraneous-import
import rimraf from 'rimraf';
import { runPrettier } from '../src/run-prettier';
import { runPrettier } from '../run-prettier';

const outputPath = path.join(__dirname, 'test-assets');
const outputFile = path.join(outputPath, 'test.js');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import { isKeyword, isIdentifierChar, isIdentifierStart } from '../src/validate-identifier';
import { isKeyword, isIdentifierChar, isIdentifierStart } from '../validate-identifier';

describe('validate-identifier', () => {
it('should return true for reserved keyword', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fs from 'fs';
import * as path from 'path';

import { JSCodeshift, Node } from '../src/types/NodePath';
import { JSCodeshift, Node } from './types/NodePath';

interface Module {
(jscodeshift: JSCodeshift, ast: Node, initOptions: string | boolean | object, action: string, transformName?: string): Node;
Expand Down Expand Up @@ -58,9 +58,9 @@ function runSingleTransform(
let module: Module;
// Assumes transform and test are on the same level
if (action) {
module = require(path.join(dirName, '../../src', 'recursive-parser.ts'));
module = require(path.join(dirName, '../../', 'recursive-parser.ts'));
} else {
module = require(path.join(dirName, '../../src', transformName, `${transformName}.ts`));
module = require(path.join(dirName, '../../src/', transformName, `${transformName}.ts`));
}
// Handle ES6 modules using default export for the transform
const transform = module.default ? module.default : module;
Expand Down
4 changes: 2 additions & 2 deletions packages/generators/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"extends": "../../tsconfig.json",
"exclude": ["src/utils/__tests__"],
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
},
"include": ["src"],
"references": [{ "path": "../utils" }]
"include": ["src"]
}
3 changes: 1 addition & 2 deletions packages/init/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"lib"
],
"dependencies": {
"@webpack-cli/generators": "^1.2.1",
"@webpack-cli/utils": "^1.2.1"
"@webpack-cli/generators": "^1.2.1"
},
"peerDependencies": {
"webpack": "4.x.x || 5.x.x",
Expand Down
3 changes: 1 addition & 2 deletions packages/init/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { initGenerator } from '@webpack-cli/generators';
import { modifyHelperUtil, npmPackagesExists } from '@webpack-cli/utils';
import { initGenerator, modifyHelperUtil, npmPackagesExists } from '@webpack-cli/generators';

class InitCommand {
async apply(cli): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion packages/init/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"rootDir": "./src"
},
"include": ["./src"],
"references": [{ "path": "../generators" }, { "path": "../utils" }]
"references": [{ "path": "../generators" }]
}
69 changes: 0 additions & 69 deletions packages/utils/CHANGELOG.md

This file was deleted.

35 changes: 0 additions & 35 deletions packages/utils/README.md

This file was deleted.

Loading