Skip to content

Commit c9284bd

Browse files
authored
Merge pull request #769 from aws-amplify/remove-inflight-dep
chore: Remove direct dependency on inflight via glob
2 parents 1ffbaf1 + 409a2ad commit c9284bd

File tree

13 files changed

+1714
-2006
lines changed

13 files changed

+1714
-2006
lines changed

dependency_licenses.txt

Lines changed: 133 additions & 406 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
"eslint-plugin-react": "^7.21.5",
105105
"eslint-plugin-spellcheck": "^0.0.17",
106106
"execa": "^5.1.1",
107-
"glob": "^7.1.6",
107+
"globby": "^11.1.0",
108108
"graphql-transformer-core": "^8.0.0",
109109
"husky": "^3.0.3",
110110
"jest": "^27.0.0",

packages/amplify-codegen-e2e-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"dotenv": "^8.6.0",
2828
"execa": "^4.1.0",
2929
"fs-extra": "^8.1.0",
30-
"glob": "^10.3.9",
30+
"globby": "^11.1.0",
3131
"ini": "^3.0.1",
3232
"jest-circus": "^27.5.1",
3333
"jest-environment-node": "^26.6.2",

packages/amplify-codegen-e2e-core/src/categories/lambda-function.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { nspawn as spawn, ExecutionContext, KEY_DOWN_ARROW, getCLIPath, getProjectMeta, getBackendAmplifyMeta, invokeFunction } from '..';
22
import { Lambda } from 'aws-sdk';
33
import { singleSelect, multiSelect, moveUp, moveDown } from '../utils/selectors';
4-
import * as glob from 'glob';
4+
import { sync } from 'globby';
55
import * as path from 'path';
66
import _ from 'lodash';
77
import { loadFeatureFlags } from '../utils/feature-flags';
@@ -467,7 +467,7 @@ const getRuntimeDisplayName = (runtime: FunctionRuntimes) => {
467467

468468
export function validateNodeModulesDirRemoval(projRoot) {
469469
let functionDir = path.join(projRoot, 'amplify', '#current-cloud-backend', 'function');
470-
const nodeModulesDirs = glob.sync('**/node_modules', {
470+
const nodeModulesDirs = sync('**/node_modules', {
471471
cwd: functionDir,
472472
absolute: true,
473473
});

packages/amplify-codegen/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@graphql-codegen/core": "2.6.6",
2828
"chalk": "^3.0.0",
2929
"fs-extra": "^8.1.0",
30-
"glob-all": "^3.1.0",
30+
"globby": "^11.1.0",
3131
"glob-parent": "^6.0.2",
3232
"graphql": "^15.5.0",
3333
"graphql-config": "^2.2.1",

packages/amplify-codegen/src/commands/models.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
const path = require('path');
22
const fs = require('fs-extra');
3-
const glob = require('glob-all');
3+
const globby = require('globby');
44
const { FeatureFlags, pathManager } = require('@aws-amplify/amplify-cli-core');
55
const { generateModels: generateModelsHelper } = require('@aws-amplify/graphql-generator');
66
const { validateAmplifyFlutterMinSupportedVersion } = require('../utils/validateAmplifyFlutterMinSupportedVersion');
77
const defaultDirectiveDefinitions = require('../utils/defaultDirectiveDefinitions');
88
const getProjectRoot = require('../utils/getProjectRoot');
99
const { getModelSchemaPathParam, hasModelSchemaPathParam } = require('../utils/getModelSchemaPathParam');
1010
const { isDataStoreEnabled } = require('graphql-transformer-core');
11+
const { normalizePathForGlobPattern } = require('../utils/input-params-manager');
1112

1213
/**
1314
* Amplify Context type.
@@ -305,7 +306,7 @@ function loadSchema(apiResourcePath) {
305306
}
306307
if (fs.pathExistsSync(schemaDirectory) && fs.lstatSync(schemaDirectory).isDirectory()) {
307308
// search recursively for graphql schema files inside `schema` directory
308-
const schemas = glob.sync([path.join(schemaDirectory, '**/*.graphql')]);
309+
const schemas = globby.sync([path.join(schemaDirectory, '**/*.graphql')].map((path) => normalizePathForGlobPattern(path)));
309310
return schemas.map(file => fs.readFileSync(file, 'utf8')).join('\n');
310311
}
311312

packages/amplify-codegen/src/commands/types.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
const path = require('path');
22
const fs = require('fs-extra');
33
const Ora = require('ora');
4-
const glob = require('glob-all');
4+
const globby = require('globby');
55
const { Source } = require('graphql');
66

77
const constants = require('../constants');
88
const { loadConfig } = require('../codegen-config');
99
const { ensureIntrospectionSchema, getFrontEndHandler, getAppSyncAPIDetails, getAppSyncAPIInfoFromProject } = require('../utils');
1010
const { generateTypes: generateTypesHelper } = require('@aws-amplify/graphql-generator');
1111
const { extractDocumentFromJavascript } = require('@aws-amplify/graphql-types-generator');
12+
const { normalizePathForGlobPattern } = require('../utils/input-params-manager');
1213

1314
async function generateTypes(context, forceDownloadSchema, withoutInit = false, decoupleFrontend = '') {
1415
let frontend = decoupleFrontend;
@@ -58,7 +59,8 @@ async function generateTypes(context, forceDownloadSchema, withoutInit = false,
5859
const target = cfg.amplifyExtension.codeGenTarget;
5960

6061
const excludes = cfg.excludes.map(pattern => `!${pattern}`);
61-
const queryFilePaths = glob.sync([...includeFiles, ...excludes], {
62+
const normalizedPatterns = [...includeFiles, ...excludes].map((path) => normalizePathForGlobPattern(path));
63+
const queryFilePaths = globby.sync(normalizedPatterns, {
6264
cwd: projectPath,
6365
absolute: true,
6466
});

packages/amplify-codegen/src/utils/input-params-manager.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const constants = require('../constants');
2+
const path = require('path');
23

34
function normalizeInputParams(context) {
45
let inputParams;
@@ -66,6 +67,12 @@ function normalizeValue(key, value) {
6667
return value;
6768
}
6869

70+
function normalizePathForGlobPattern(pattern) {
71+
const splits = pattern.split(path.win32.sep);
72+
return splits.join(path.posix.sep);
73+
}
74+
6975
module.exports = {
7076
normalizeInputParams,
77+
normalizePathForGlobPattern,
7178
};

packages/amplify-codegen/tests/commands/types.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { sync } = require('glob-all');
1+
const globby = require('globby');
22
const path = require('path');
33
const { generateTypes: generateTypesHelper } = require('@aws-amplify/graphql-generator');
44
const fs = require('fs-extra');
@@ -19,7 +19,7 @@ const MOCK_CONTEXT = {
1919
},
2020
};
2121

22-
jest.mock('glob-all');
22+
jest.mock('globby');
2323
jest.mock('@aws-amplify/graphql-generator');
2424
jest.mock('@aws-amplify/graphql-types-generator');
2525
jest.mock('../../src/codegen-config');
@@ -47,7 +47,7 @@ const MOCK_PROJECT = {
4747
region: MOCK_REGION,
4848
},
4949
};
50-
sync.mockReturnValue(MOCK_QUERIES);
50+
globby.sync.mockReturnValue(MOCK_QUERIES);
5151
const MOCK_APIS = [
5252
{
5353
id: MOCK_API_ID,
@@ -80,7 +80,7 @@ describe('command - types', () => {
8080
await generateTypes(MOCK_CONTEXT, forceDownload);
8181
expect(getFrontEndHandler).toHaveBeenCalledWith(MOCK_CONTEXT);
8282
expect(loadConfig).toHaveBeenCalledWith(MOCK_CONTEXT, false);
83-
expect(sync).toHaveBeenCalledWith([MOCK_INCLUDE_PATH, `!${MOCK_EXCLUDE_PATH}`], {
83+
expect(globby.sync).toHaveBeenCalledWith([MOCK_INCLUDE_PATH, `!${MOCK_EXCLUDE_PATH}`], {
8484
cwd: MOCK_PROJECT_ROOT,
8585
absolute: true,
8686
});
@@ -154,13 +154,13 @@ describe('command - types', () => {
154154
MOCK_PROJECT.includes = [];
155155
await generateTypes(MOCK_CONTEXT, true);
156156
expect(generateTypesHelper).not.toHaveBeenCalled();
157-
expect(sync).not.toHaveBeenCalled();
157+
expect(globby.sync).not.toHaveBeenCalled();
158158
});
159159

160160
it('should not generate type when generatedFileName is missing', async () => {
161161
MOCK_PROJECT.amplifyExtension.generatedFileName = '';
162162
await generateTypes(MOCK_CONTEXT, true);
163163
expect(generateTypesHelper).not.toHaveBeenCalled();
164-
expect(sync).not.toHaveBeenCalled();
164+
expect(globby.sync).not.toHaveBeenCalled();
165165
});
166166
});

packages/graphql-types-generator/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"common-tags": "^1.8.0",
4444
"core-js": "^3.6.4",
4545
"fs-extra": "^8.1.0",
46-
"glob": "^7.1.6",
46+
"globby": "^11.1.0",
4747
"graphql": "^15.5.0",
4848
"inflected": "^2.0.4",
4949
"prettier": "^1.19.1",
@@ -55,7 +55,6 @@
5555
"@types/babel-generator": "^6.25.0",
5656
"@types/common-tags": "^1.8.0",
5757
"@types/fs-extra": "^8.1.0",
58-
"@types/glob": "^7.1.1",
5958
"@types/inflected": "^1.1.29",
6059
"@types/node": "^10.17.13",
6160
"@types/prettier": "^1.19.0",

0 commit comments

Comments
 (0)