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

chore: complete cli core migration #12408

Merged
merged 15 commits into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jest.mock('@aws-amplify/amplify-prompts', () => ({
},
}));

jest.mock('amplify-cli-core', () => ({
...(jest.requireActual('amplify-cli-core') as {}),
jest.mock('@aws-amplify/amplify-cli-core', () => ({
...(jest.requireActual('@aws-amplify/amplify-cli-core') as {}),
FeatureFlags: {
getBoolean: () => false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jest.mock('@aws-amplify/amplify-prompts', () => ({
},
}));

jest.mock('amplify-cli-core', () => ({
...(jest.requireActual('amplify-cli-core') as {}),
jest.mock('@aws-amplify/amplify-cli-core', () => ({
...(jest.requireActual('@aws-amplify/amplify-cli-core') as {}),
stateManager: {
getMeta: jest
.fn()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jest.mock('../../provider-utils/awscloudformation/auth-inputs-manager/auth-input
})),
}));

jest.mock('amplify-cli-core');
jest.mock('@aws-amplify/amplify-cli-core');

const stateManagerMock = stateManager as jest.Mocked<typeof stateManager>;
stateManagerMock.getMeta.mockReturnValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jest.mock('fs-extra', () => ({

jest.mock('@aws-amplify/amplify-prompts');

jest.mock('amplify-cli-core', () => ({
...(jest.requireActual('amplify-cli-core') as Record<string, unknown>),
jest.mock('@aws-amplify/amplify-cli-core', () => ({
...(jest.requireActual('@aws-amplify/amplify-cli-core') as Record<string, unknown>),
FeatureFlags: {
getBoolean: jest.fn().mockReturnValue(true),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { AuthInputState } from '../../../../provider-utils/awscloudformation/aut

jest.mock('fs-extra');

jest.mock('amplify-cli-core', () => ({
...(jest.requireActual('amplify-cli-core') as {}),
jest.mock('@aws-amplify/amplify-cli-core', () => ({
...(jest.requireActual('@aws-amplify/amplify-cli-core') as {}),
pathManager: {
getBackendDirPath: jest.fn().mockReturnValue('mockbackendDirPath'),
findProjectRoot: jest.fn().mockReturnValue('mockProject'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { $TSContext } from '@aws-amplify/amplify-cli-core';
import process from 'process';
import { AmplifyAuthTransform } from '../../../../provider-utils/awscloudformation/auth-stack-builder';

jest.mock('amplify-cli-core', () => ({
...(jest.requireActual('amplify-cli-core') as {}),
jest.mock('@aws-amplify/amplify-cli-core', () => ({
...(jest.requireActual('@aws-amplify/amplify-cli-core') as {}),
stateManager: {
getLocalEnvInfo: jest.fn().mockReturnValue('testenv'),
getMeta: jest.fn().mockReturnValue({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { $TSContext } from '@aws-amplify/amplify-cli-core';
import { AmplifyUserPoolGroupTransform } from '../../../../provider-utils/awscloudformation/auth-stack-builder';

jest.mock('amplify-cli-core', () => ({
...(jest.requireActual('amplify-cli-core') as Record<string, unknown>),
jest.mock('@aws-amplify/amplify-cli-core', () => ({
...(jest.requireActual('@aws-amplify/amplify-cli-core') as Record<string, unknown>),
stateManager: {
getLocalEnvInfo: jest.fn().mockReturnValue('testEnv'),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jest.mock('../../../../provider-utils/awscloudformation/utils/message-printer');
// eslint-disable-next-line spellcheck/spell-checker
jest.mock('../../../../provider-utils/awscloudformation/utils/amplify-meta-updaters');
jest.mock('../../../../provider-utils/awscloudformation/utils/auth-sms-workflow-helper');
jest.mock('amplify-cli-core');
jest.mock('@aws-amplify/amplify-cli-core');

const getSupportedServicesMock = getSupportedServices as jest.MockedFunction<typeof getSupportedServices>;
getSupportedServicesMock.mockReturnValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { $TSContext } from '@aws-amplify/amplify-cli-core';
import { updateConfigOnEnvInit } from '../../../provider-utils/awscloudformation/index';

jest.mock('@aws-amplify/amplify-environment-parameters');
jest.mock('amplify-cli-core', () => ({
...(jest.requireActual('amplify-cli-core') as {}),
jest.mock('@aws-amplify/amplify-cli-core', () => ({
...(jest.requireActual('@aws-amplify/amplify-cli-core') as {}),
JSONUtilities: {
writeJson: jest.fn(),
readJson: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jest.mock('../../../../provider-utils/awscloudformation/service-walkthroughs/aut
structureOAuthMetadata: jest.fn((result) => (result.include = 'this value')),
}));

jest.mock('amplify-cli-core', () => {
jest.mock('@aws-amplify/amplify-cli-core', () => {
return {
...(jest.requireActual('amplify-cli-core') as {}),
...(jest.requireActual('@aws-amplify/amplify-cli-core') as {}),
FeatureFlags: {
getBoolean: jest.fn().mockImplementation((name, defaultValue) => {
if (name === 'auth.enableCaseInsensitivity') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jest.mock('@aws-amplify/amplify-prompts', () => ({
},
}));

jest.mock('amplify-cli-core', () => ({
...(jest.requireActual('amplify-cli-core') as {}),
jest.mock('@aws-amplify/amplify-cli-core', () => ({
...(jest.requireActual('@aws-amplify/amplify-cli-core') as {}),
stateManager: {
getMeta: jest.fn().mockReturnValue({
auth: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { AuthInputState } from '../../../../provider-utils/awscloudformation/aut
import { AttributeType } from '../../../../provider-utils/awscloudformation/service-walkthrough-types/awsCognito-user-input-types';
import { getAuthTriggerStackCfnParameters } from '../../../../provider-utils/awscloudformation/utils/get-auth-trigger-stack-cfn-parameters';

jest.mock('amplify-cli-core', () => ({
...jest.requireActual('amplify-cli-core'),
jest.mock('@aws-amplify/amplify-cli-core', () => ({
...jest.requireActual('@aws-amplify/amplify-cli-core'),
pathManager: {
getBackendDirPath: jest.fn().mockReturnValue('mockDirPath'),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { printSMSSandboxWarning } from '../../../../provider-utils/awscloudforma
import { BannerMessage } from '@aws-amplify/amplify-cli-core';
import { printer } from '@aws-amplify/amplify-prompts';
import os from 'os';
jest.mock('amplify-cli-core');

jest.mock('@aws-amplify/amplify-cli-core');
jest.mock('@aws-amplify/amplify-prompts');

describe('printSMSSandboxWarning', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import * as path from 'path';
jest.mock('@aws-amplify/amplify-prompts');
jest.mock('fs-extra');

jest.mock('amplify-cli-core', () => ({
...(jest.requireActual('amplify-cli-core') as {}),
jest.mock('@aws-amplify/amplify-cli-core', () => ({
...(jest.requireActual('@aws-amplify/amplify-cli-core') as {}),
pathManager: {
findProjectRoot: jest.fn().mockReturnValue('somePath'),
getBackendDirPath: jest.fn().mockReturnValue('mockProjectPath'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { stateManager } from '@aws-amplify/amplify-cli-core';
import { projectHasAuth } from '../../../../provider-utils/awscloudformation/utils/project-has-auth';

jest.mock('amplify-cli-core');
jest.mock('@aws-amplify/amplify-cli-core');

describe('auth category dependency check', () => {
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { updateUserPoolGroups } from '../../../../provider-utils/awscloudformati
import { createAdminAuthFunction } from '../../../../provider-utils/awscloudformation/utils/synthesize-resources';
import * as path from 'path';

jest.mock('amplify-cli-core');
jest.mock('@aws-amplify/amplify-cli-core');
jest.mock('fs-extra');
jest.mock('../../../../provider-utils/awscloudformation/utils/generate-user-pool-group-stack-template');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jest.mock('amplify-cli-core', () => {
jest.mock('@aws-amplify/amplify-cli-core', () => {
return {
FeatureFlags: {
getBoolean: jest.fn().mockImplementation((name, defaultValue) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-category-auth/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const path = require('path');
const sequential = require('promise-sequential');

const { validateAddAuthRequest, validateUpdateAuthRequest, validateImportAuthRequest } = require('amplify-util-headless-input');
const { stateManager, AmplifySupportedService, JSONUtilities } = require('amplify-cli-core');
const { stateManager, AmplifySupportedService, JSONUtilities } = require('@aws-amplify/amplify-cli-core');
const { printer } = require('@aws-amplify/amplify-prompts');
const { ensureEnvParamManager } = require('@aws-amplify/amplify-environment-parameters');
const defaults = require('./provider-utils/awscloudformation/assets/cognito-defaults');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getLocalFunctionSecretNames } from '../provider-utils/awscloudformation
import { getAppId, secretsPathAmplifyAppIdKey } from '../provider-utils/awscloudformation/secrets/secretName';

jest.mock('promise-sequential');
jest.mock('amplify-cli-core');
jest.mock('@aws-amplify/amplify-cli-core');

jest.mock('../provider-utils/awscloudformation/secrets/functionSecretsStateManager');
jest.mock('../provider-utils/awscloudformation/secrets/secretName');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { buildFunction } from '../../../provider-utils/awscloudformation/utils/b
import { getBuilder } from '../../..';
import { BuildType } from '@aws-amplify/amplify-function-plugin-interface';

jest.mock('amplify-cli-core');
jest.mock('@aws-amplify/amplify-cli-core');
const stateManager_mock = stateManager as jest.Mocked<typeof stateManager>;
stateManager_mock.getMeta.mockReturnValue({
providers: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as stateManagerModule from '../../../../provider-utils/awscloudformatio
import { getAppId, getFunctionSecretPrefix } from '../../../../provider-utils/awscloudformation/secrets/secretName';
import { SSMClientWrapper } from '../../../../provider-utils/awscloudformation/secrets/ssmClientWrapper';

jest.mock('amplify-cli-core');
jest.mock('@aws-amplify/amplify-cli-core');
jest.mock('../../../../provider-utils/awscloudformation/secrets/ssmClientWrapper');
jest.mock('../../../../provider-utils/awscloudformation/secrets/secretsCfnModifier');
jest.mock('../../../../provider-utils/awscloudformation/secrets/secretName');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { LayerVersionMetadata } from '../../../../provider-utils/awscloudformati

jest.mock('../../../../provider-utils/awscloudformation/utils/addLayerToFunctionUtils');
jest.mock('../../../../provider-utils/awscloudformation/utils/layerCloudState');
jest.mock('amplify-cli-core');
jest.mock('@aws-amplify/amplify-cli-core');

const stateManager_mock = stateManager as jest.Mocked<typeof stateManager>;
stateManager_mock.getMeta.mockReturnValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const backendDirPathStub = 'backendDirPath';

jest.mock('../../../../provider-utils/awscloudformation/utils/cloudformationHelpers');

jest.mock('amplify-cli-core', () => ({
jest.mock('@aws-amplify/amplify-cli-core', () => ({
stateManager: {
getMeta: jest.fn(),
},
Expand Down Expand Up @@ -93,7 +93,7 @@ test('check CFN resources', async () => {

test('env resources for CFN for DDB table and api', async () => {
const contextStub = {
...jest.requireActual('amplify-cli-core'),
...jest.requireActual('@aws-amplify/amplify-cli-core'),
print: {
info: () => jest.fn,
},
Expand All @@ -110,7 +110,7 @@ test('env resources for CFN for DDB table and api', async () => {

test('env resources for CFN for auth and storage for api', async () => {
const contextStub = {
...jest.requireActual('amplify-cli-core'),
...jest.requireActual('@aws-amplify/amplify-cli-core'),
print: {
info: () => jest.fn,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ describe('remove walkthough test', () => {
},
};

jest.mock('amplify-cli-core', () => ({
...jest.requireActual('amplify-cli-core'),
jest.mock('@aws-amplify/amplify-cli-core', () => ({
...jest.requireActual('@aws-amplify/amplify-cli-core'),
promptConfirmationRemove: jest.fn().mockReturnValue(true),
stateManager: {
getLocalEnvInfo: jest.fn().mockReturnValue({ envName }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { $TSContext, pathManager } from '@aws-amplify/amplify-cli-core';
import { BuildType, FunctionRuntimeLifecycleManager } from '@aws-amplify/amplify-function-plugin-interface';
import { buildFunction } from '../../../../provider-utils/awscloudformation/utils/buildFunction';

jest.mock('amplify-cli-core');
jest.mock('@aws-amplify/amplify-cli-core');

const pathManager_mock = pathManager as jest.Mocked<typeof pathManager>;
pathManager_mock.getBackendDirPath.mockReturnValue('mockpath');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FunctionRuntimeLifecycleManager } from '@aws-amplify/amplify-function-p
import { buildLayer } from '../../../../provider-utils/awscloudformation/utils/buildLayer';
import { loadLayerConfigurationFile } from '../../../../provider-utils/awscloudformation/utils/layerConfiguration';

jest.mock('amplify-cli-core');
jest.mock('@aws-amplify/amplify-cli-core');
jest.mock('../../../../provider-utils/awscloudformation/utils/layerConfiguration');

const pathManager_mock = pathManager as jest.Mocked<typeof pathManager>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { pathManager, stateManager, readCFNTemplate, writeCFNTemplate, CFNTemplateFormat } from '@aws-amplify/amplify-cli-core';
import { ensureLambdaExecutionRoleOutputs } from '../../../../provider-utils/awscloudformation/utils/ensure-lambda-arn-outputs';

jest.mock('amplify-cli-core');
jest.mock('@aws-amplify/amplify-cli-core');
const pathManagerMock = pathManager as jest.Mocked<typeof pathManager>;
const stateManagerMock = stateManager as jest.Mocked<typeof stateManager>;
const readCFNTemplateMock = readCFNTemplate as jest.MockedFunction<typeof readCFNTemplate>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { prompter } from '@aws-amplify/amplify-prompts';
import * as envVarHelper from '../../../../provider-utils/awscloudformation/utils/environmentVariablesHelper';
import * as uuid from 'uuid';

jest.mock('amplify-cli-core');
jest.mock('@aws-amplify/amplify-cli-core');
jest.mock('@aws-amplify/amplify-prompts');
jest.mock('uuid');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { $TSContext } from '@aws-amplify/amplify-cli-core';
jest.mock('fs-extra');
jest.mock('../../../../provider-utils/awscloudformation/utils/loadFunctionParameters');
jest.mock('path');
jest.mock('amplify-cli-core', () => ({
jest.mock('@aws-amplify/amplify-cli-core', () => ({
JSONUtilities: {
readJson: jest.fn(),
writeJson: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
PermissionEnum,
} from '../../../../provider-utils/awscloudformation/utils/layerParams';

jest.mock('amplify-cli-core');
jest.mock('@aws-amplify/amplify-cli-core');
const pathManager_mock = pathManager as jest.Mocked<typeof pathManager>;
const stateManager_mock = stateManager as jest.Mocked<typeof stateManager>;
pathManager_mock.getResourceDirectoryPath.mockReturnValue('fakeProject/amplify/backend/myLayer/');
Expand Down Expand Up @@ -65,7 +65,7 @@ function validateOutput(layerCfn) {

describe('test layer CFN generation functions', () => {
beforeAll(() => {
jest.mock('amplify-cli-core', () => ({
jest.mock('@aws-amplify/amplify-cli-core', () => ({
stateManager: {
getLocalEnvInfo: jest.fn().mockReturnValue('testenv'),
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { JSONUtilities } from '@aws-amplify/amplify-cli-core';
import { loadFunctionParameters } from '../../../../provider-utils/awscloudformation/utils/loadFunctionParameters';

jest.mock('amplify-cli-core', () => ({
jest.mock('@aws-amplify/amplify-cli-core', () => ({
JSONUtilities: {
readJson: jest.fn(),
writeJson: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PackageRequestMeta } from '../../../../provider-utils/awscloudformation
import { zipPackage } from '../../../../provider-utils/awscloudformation/utils/zipResource';

jest.mock('fs-extra');
jest.mock('amplify-cli-core');
jest.mock('@aws-amplify/amplify-cli-core');
jest.mock('../../../../provider-utils/awscloudformation/utils/functionPluginLoader');
jest.mock('../../../../provider-utils/awscloudformation/utils/zipResource');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { LayerCloudState } from '../../../../provider-utils/awscloudformation/ut
import { loadLayerConfigurationFile } from '../../../../provider-utils/awscloudformation/utils/layerConfiguration';

jest.mock('fs-extra');
jest.mock('amplify-cli-core');
jest.mock('@aws-amplify/amplify-cli-core');
jest.mock('../../../../provider-utils/awscloudformation/utils/functionPluginLoader');
jest.mock('../../../../provider-utils/awscloudformation/utils/layerConfiguration');
jest.mock('../../../../provider-utils/awscloudformation/utils/layerCloudState');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { $TSContext, JSONUtilities, pathManager } from '@aws-amplify/amplify-cli
import { LambdaLayer } from '@aws-amplify/amplify-function-plugin-interface';
import { saveMutableState } from '../../../../provider-utils/awscloudformation/utils/storeResources';

jest.mock('amplify-cli-core', () => ({
jest.mock('@aws-amplify/amplify-cli-core', () => ({
JSONUtilities: {
readJson: jest.fn(),
writeJson: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jest.mock('../../../../provider-utils/awscloudformation/utils/loadFunctionParame
jest.mock('path');
jest.mock('../../../../provider-utils/awscloudformation/service-walkthroughs/lambda-walkthrough');

jest.mock('amplify-cli-core', () => ({
jest.mock('@aws-amplify/amplify-cli-core', () => ({
JSONUtilities: {
readJson: jest.fn(),
writeJson: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { $TSContext } from 'amplify-cli-core';

import { $TSContext } from '@aws-amplify/amplify-cli-core';
import { LayerCloudState } from '../../provider-utils/awscloudformation/utils/layerCloudState';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { run } from '../../../commands/geo/add';
const mockAddResource = addResource as jest.MockedFunction<typeof addResource>;
mockAddResource.mockImplementation(async (_, service: string) => service);

jest.mock('amplify-cli-core');
jest.mock('@aws-amplify/amplify-cli-core');
jest.mock('../../../provider-controllers/index');

describe('add command tests', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mockRemoveResource.mockImplementation((context: $TSContext, service: string): Pr
});
});

jest.mock('amplify-cli-core');
jest.mock('@aws-amplify/amplify-cli-core');
jest.mock('../../../provider-controllers');

describe('remove command tests', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { run } from '../../../commands/geo/update';
const mockUpdateResource = updateResource as jest.MockedFunction<typeof updateResource>;
mockUpdateResource.mockImplementation(async (_, service: string) => service);

jest.mock('amplify-cli-core');
jest.mock('@aws-amplify/amplify-cli-core');
jest.mock('../../../provider-controllers/index');

describe('update command tests', () => {
Expand Down
Loading