Skip to content
Merged
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
30 changes: 21 additions & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
{
"plugins": ["jest"],
"extends": ["standard", "plugin:jest/recommended"],
"globals": {
"n": "readonly",
"r": "readonly",
"assertDependencies": "readonly",
"assertNodeEngines": "readonly"
}
"extends": ["standard"],
"parserOptions": {
"ecmaVersion": 2022,
"sourceType": "module"
},
"globals": {
"n": "readonly",
"r": "readonly",
"assertDependencies": "readonly",
"assertNodeEngines": "readonly",
"basicGeneratorOptions": "readonly",
"vi": "readonly",
"describe": "readonly",
"it": "readonly",
"test": "readonly",
"expect": "readonly",
"beforeEach": "readonly",
"afterEach": "readonly",
"beforeAll": "readonly",
"afterAll": "readonly"
}
}
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

const utils = require('./lib/utils')
const ActionGenerator = require('./lib/ActionGenerator')
const EventsGenerator = require('./lib/EventsGenerator')
const constants = require('./lib/constants')
const commonTemplates = require('./lib/common-templates')
import * as utils from './lib/utils.js'
import ActionGenerator from './lib/ActionGenerator.js'
import EventsGenerator from './lib/EventsGenerator.js'
import * as constants from './lib/constants.js'
import commonTemplates from './lib/common-templates/index.js'

module.exports = {
export {
utils,
constants,
ActionGenerator,
Expand Down
32 changes: 0 additions & 32 deletions jest.config.js

This file was deleted.

12 changes: 6 additions & 6 deletions lib/ActionGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

const path = require('path')
const upath = require('upath')
import path from 'node:path'
import upath from 'upath'

const Generator = require('yeoman-generator')
const utils = require('./utils')
const { nodeEngines, defaultRuntimeKind } = require('./constants')
import Generator from 'yeoman-generator'
import * as utils from './utils.js'
import { nodeEngines, defaultRuntimeKind } from './constants.js'

class ActionGenerator extends Generator {
constructor (args, opts) {
Expand Down Expand Up @@ -242,4 +242,4 @@ Note: characters can only be split by '-'.
}
}

module.exports = ActionGenerator
export default ActionGenerator
20 changes: 10 additions & 10 deletions lib/EventsGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

const utils = require('./utils')
const eventsSdk = require('@adobe/aio-lib-events')
const config = require('@adobe/aio-lib-core-config')
const { getToken } = require('@adobe/aio-lib-ims')
const { CLI } = require('@adobe/aio-lib-ims/src/context')
import * as utils from './utils.js'
import eventsSdk from '@adobe/aio-lib-events'
import config from '@adobe/aio-lib-core-config'
import imsLib from '@adobe/aio-lib-ims'
import { CLI } from '@adobe/aio-lib-ims/src/context.js'

const ActionGenerator = require('./ActionGenerator')
const { promptForEventsOfInterest, getProviderMetadataToProvidersExistingMap } = require('./events/EventsOfInterestHelper')
const { promptForRuntimeAction } = require('./events/RuntimeActionForEventsHelper')
import ActionGenerator from './ActionGenerator.js'
import { promptForEventsOfInterest, getProviderMetadataToProvidersExistingMap } from './events/EventsOfInterestHelper.js'
import { promptForRuntimeAction } from './events/RuntimeActionForEventsHelper.js'
const eventsProvidermetadataToProviderMapping = 'AIO_EVENTS_PROVIDERMETADATA_TO_PROVIDER_MAPPING'

class EventsGenerator extends ActionGenerator {
Expand Down Expand Up @@ -47,7 +47,7 @@ class EventsGenerator extends ActionGenerator {
this.env.error('Incomplete .aio configuration, please import a valid Adobe Developer Console configuration via `aio app use` first.')
}
const orgCode = this.projectConfig.org.ims_org_id
const accessToken = await getToken(CLI)
const accessToken = await imsLib.getToken(CLI)
const X_API_KEY = process.env.SERVICE_API_KEY
const eventsClient = await eventsSdk.init(orgCode, X_API_KEY, accessToken)
return eventsClient
Expand Down Expand Up @@ -175,4 +175,4 @@ class EventsGenerator extends ActionGenerator {
}
}

module.exports = EventsGenerator
export default EventsGenerator
7 changes: 5 additions & 2 deletions lib/common-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
const path = require('path')
import path from 'node:path'
import { fileURLToPath } from 'node:url'

module.exports = {
const __dirname = path.dirname(fileURLToPath(import.meta.url))

export default {
'stub-action.e2e': path.resolve(__dirname, './stub-action.e2e.js'),
'stub-action': path.resolve(__dirname, './stub-action.js'),
utils: path.resolve(__dirname, './utils.js'),
Expand Down
38 changes: 18 additions & 20 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,22 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

module.exports = {
isLoopingPrompts: false,
actionsDirname: 'actions',
dotenvFilename: '.env',
manifestPackagePlaceholder: '__APP_PACKAGE__',
sdkCodes: {
analytics: 'AdobeAnalyticsSDK',
assetCompute: 'AssetComputeSDK',
campaign: 'CampaignSDK',
customerProfile: 'McDataServicesSdk',
target: 'AdobeTargetSDK'
},
ciDirName: '.github',
commonDependencyVersions: {
'@adobe/aio-sdk': '^6'
},
appConfigFile: 'app.config.yaml',
runtimeManifestKey: 'runtimeManifest',
nodeEngines: '>=18',
defaultRuntimeKind: 'nodejs:22'
export const isLoopingPrompts = false
export const actionsDirname = 'actions'
export const dotenvFilename = '.env'
export const manifestPackagePlaceholder = '__APP_PACKAGE__'
export const sdkCodes = {
analytics: 'AdobeAnalyticsSDK',
assetCompute: 'AssetComputeSDK',
campaign: 'CampaignSDK',
customerProfile: 'McDataServicesSdk',
target: 'AdobeTargetSDK'
}
export const ciDirName = '.github'
export const commonDependencyVersions = {
'@adobe/aio-sdk': '^6'
}
export const appConfigFile = 'app.config.yaml'
export const runtimeManifestKey = 'runtimeManifest'
export const nodeEngines = '>=18'
export const defaultRuntimeKind = 'nodejs:22'
6 changes: 3 additions & 3 deletions lib/events/EventsOfInterestHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

const { getAllEntitledProvidersForOrg, selectEventMetadataForProvider, selectProviderForProviderMetadata } = require('./ProviderHelper')
const { getEntitledProviderMetadataForOrg, getProviderMetadata } = require('./ProviderMetadataHelper')
import { getAllEntitledProvidersForOrg, selectEventMetadataForProvider, selectProviderForProviderMetadata } from './ProviderHelper.js'
import { getEntitledProviderMetadataForOrg, getProviderMetadata } from './ProviderMetadataHelper.js'

async function promptForEventsOfInterest (eventsClient, obj, options) {
// get all entitled provider metadata for the org
Expand Down Expand Up @@ -86,7 +86,7 @@ function getProviderMetadataToProvidersExistingMap (providerMetadataToProviderMa
return {}
}

module.exports = {
export {
promptForEventsOfInterest,
getProviderMetadataToProvidersExistingMap
}
2 changes: 1 addition & 1 deletion lib/events/ProviderHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async function selectEventMetadataForProvider (providerSelected, eventMetadataCh
return eventMetadataSelection
}

module.exports = {
export {
getAllEntitledProvidersForOrg,
selectProviderForProviderMetadata,
selectEventMetadataForProvider
Expand Down
2 changes: 1 addition & 1 deletion lib/events/ProviderMetadataHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function getProviderMetadata (obj, providerMetadataList, options) {
return providerMetadataIds
}

module.exports = {
export {
getEntitledProviderMetadataForOrg,
getProviderMetadata
}
2 changes: 1 addition & 1 deletion lib/events/RuntimeActionForEventsHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ function getExistingActionNames (runtimeManifest, pkgName) {
return actionNames
}

module.exports = {
export {
promptForRuntimeAction
}
10 changes: 5 additions & 5 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

const path = require('path')
const yaml = require('js-yaml')
const { EOL } = require('os')
const { appConfigFile, dotenvFilename } = require('./constants')
import path from 'node:path'
import yaml from 'js-yaml'
import { EOL } from 'node:os'
import { appConfigFile, dotenvFilename } from './constants.js'

function atLeastOne (input) {
if (input.length === 0) {
Expand Down Expand Up @@ -127,7 +127,7 @@ function appendVarsToDotenv (generator, label, envVariable, value) {
generator.fs.append(file, content)
}

module.exports = {
export {
atLeastOne,
guessProjectName,
addDependencies,
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
"name": "@adobe/generator-app-common-lib",
"version": "3.0.2",
"description": "",
"type": "module",
"main": "index.js",
"scripts": {
"test": "npm run unit-tests && npm run lint",
"lint": "eslint .",
"unit-tests": "jest -c ./jest.config.js"
"unit-tests": "vitest run --coverage",
"test:watch": "vitest"
},
"author": "Adobe Inc.",
"license": "Apache-2.0",
Expand All @@ -19,18 +21,17 @@
},
"devDependencies": {
"@adobe/eslint-config-aio-lib-config": "^4.0.0",
"@types/jest": "^29.5.0",
"@vitest/coverage-v8": "^2.1.0",
"eol": "^0.9.1",
"eslint": "^8.57.1",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-jsdoc": "^48.11.0",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.6.0",
"jest": "^29",
"stdout-stderr": "^0.1.13"
"stdout-stderr": "^0.1.13",
"vitest": "^2.1.0"
},
"dependencies": {
"@adobe/aio-lib-core-config": "^5",
Expand All @@ -42,6 +43,6 @@
"lodash.clonedeep": "^4.5.0",
"process": "^0.11.10",
"upath": "^2.0.1",
"yeoman-generator": "^5.5.2"
"yeoman-generator": "^8"
}
}
23 changes: 11 additions & 12 deletions test/lib/ActionGenerator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

const path = require('path')
const cloneDeep = require('lodash.clonedeep')
import path from 'node:path'
import cloneDeep from 'lodash.clonedeep'

const constants = require('../../lib/constants')
import * as constants from '../../lib/constants.js'

jest.mock('yeoman-generator')
import ActionGenerator from '../../lib/ActionGenerator.js'
import Generator from 'yeoman-generator'
import * as utils from '../../lib/utils.js'

const ActionGenerator = require('../../lib/ActionGenerator')
const Generator = require('yeoman-generator')

jest.mock('../../lib/utils.js')
const utils = require('../../lib/utils.js')
vi.mock('yeoman-generator')
vi.mock('../../lib/utils.js')

const generatorOptions = cloneDeep(global.basicGeneratorOptions)

Expand Down Expand Up @@ -52,7 +51,7 @@ describe('implementation', () => {
})
describe('constructor', () => {
test('accept options', () => {
const spy = jest.spyOn(ActionGenerator.prototype, 'option')
const spy = vi.spyOn(ActionGenerator.prototype, 'option')
// eslint-disable-next-line no-new
new ActionGenerator()
expect(spy).toHaveBeenCalledWith('skip-prompt', { default: false })
Expand All @@ -72,7 +71,7 @@ describe('implementation', () => {
let promptSpy
let actionGenerator
beforeEach(() => {
promptSpy = jest.spyOn(ActionGenerator.prototype, 'prompt')
promptSpy = vi.spyOn(ActionGenerator.prototype, 'prompt')
actionGenerator = new ActionGenerator()
actionGenerator.options = { 'skip-prompt': false }
})
Expand Down Expand Up @@ -169,7 +168,7 @@ Note: characters can only be split by '-'.
beforeEach(() => {
actionGenerator = new ActionGenerator()
actionGenerator.options = { 'skip-prompt': false }
actionGenerator.fs = { copyTpl: jest.fn() }
actionGenerator.fs = { copyTpl: vi.fn() }

// mock path resolvers
actionGenerator.templatePath = p => path.join('/fakeTplDir', p)
Expand Down
Loading
Loading