Skip to content

Commit 39713f0

Browse files
authored
Simplified folder structure (#60)
* chore: Surfaced the folders in src * chore: Updated relative import paths * chore: Surfaced the folders in tests * chore: Updated relative import paths (tests) * chore: Updated relative import paths (src) * refactor: Renamed tests --------- Co-authored-by: ijlee2 <[email protected]>
1 parent b12d041 commit 39713f0

File tree

99 files changed

+349
-356
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+349
-356
lines changed

src/index.ts

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,40 @@
1-
import { migrateEmberAddon } from './migration/index.js';
1+
import {
2+
analyzeAddon,
3+
createFilesFromBlueprints,
4+
createOptions,
5+
moveAddonFiles,
6+
moveProjectRootFiles,
7+
moveTestAppFiles,
8+
updateAddonPackageJson,
9+
updateAddonTsConfigJson,
10+
updateTestAppPackageJson,
11+
updateTestAppTsConfigJson,
12+
} from './steps/index.js';
213
import type { CodemodOptions } from './types/index.js';
314

415
export function runCodemod(codemodOptions: CodemodOptions): void {
5-
migrateEmberAddon(codemodOptions);
16+
const options = createOptions(codemodOptions);
17+
const { isV1Addon } = options.packages.addon;
18+
19+
// Guarantee idempotency
20+
if (!isV1Addon) {
21+
return;
22+
}
23+
24+
// Prepare for migration
25+
const context = analyzeAddon(options);
26+
27+
// Preserve code
28+
moveAddonFiles(options);
29+
moveTestAppFiles(options);
30+
moveProjectRootFiles(options);
31+
32+
// Get the latest code from blueprints
33+
createFilesFromBlueprints(context, options);
34+
35+
// Fine-tune individual files
36+
updateAddonPackageJson(context, options);
37+
updateAddonTsConfigJson(options);
38+
updateTestAppPackageJson(options);
39+
updateTestAppTsConfigJson(options);
640
}

src/migration/ember-addon/index.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/migration/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/migration/ember-addon/steps/analyze-addon.ts renamed to src/steps/analyze-addon.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { findFiles, renamePathByDirectory } from '@codemod-utils/files';
22

3-
import type { Context, Options } from '../../../types/index.js';
4-
import { getVersion } from '../../../utils/blueprints.js';
3+
import type { Context, Options } from '../types/index.js';
4+
import { getVersion } from '../utils/blueprints.js';
55

66
function getAppReexports(options: Options): string[] {
77
const { projectRoot } = options;

src/migration/ember-addon/steps/create-files-from-blueprints.ts renamed to src/steps/create-files-from-blueprints.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { join } from 'node:path';
44
import { processTemplate } from '@codemod-utils/blueprints';
55
import { createFiles, findFiles } from '@codemod-utils/files';
66

7-
import type { Context, Options } from '../../../types/index.js';
8-
import { blueprintsRoot } from '../../../utils/blueprints.js';
7+
import type { Context, Options } from '../types/index.js';
8+
import { blueprintsRoot } from '../utils/blueprints.js';
99

1010
function getFilesToSkip(options: Options): string[] {
1111
const { packageManager, packages } = options;

src/migration/ember-addon/steps/create-options.ts renamed to src/steps/create-options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { findFiles, unionize } from '@codemod-utils/files';
22
import { readPackageJson, validatePackageJson } from '@codemod-utils/json';
33

4-
import type { CodemodOptions, Options } from '../../../types/index.js';
4+
import type { CodemodOptions, Options } from '../types/index.js';
55

66
type AddonPackage = Options['packages']['addon'];
77
type PackageManager = Options['packageManager'];
File renamed without changes.

src/migration/ember-addon/steps/move-addon-files.ts renamed to src/steps/move-addon-files.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
removeFiles,
66
} from '@codemod-utils/files';
77

8-
import type { Options } from '../../../types/index.js';
8+
import type { Options } from '../types/index.js';
99

1010
function moveAddonFolder(options: Options): void {
1111
const { locations, projectRoot } = options;

src/migration/ember-addon/steps/move-project-root-files.ts renamed to src/steps/move-project-root-files.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
unionize,
88
} from '@codemod-utils/files';
99

10-
import type { Options } from '../../../types/index.js';
10+
import type { Options } from '../types/index.js';
1111

1212
function copyToAddon(options: Options): void {
1313
const { locations, projectRoot } = options;

src/migration/ember-addon/steps/move-test-app-files.ts renamed to src/steps/move-test-app-files.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { join } from 'node:path';
33

44
import { findFiles, mapFilePaths, moveFiles } from '@codemod-utils/files';
55

6-
import type { Options } from '../../../types/index.js';
6+
import type { Options } from '../types/index.js';
77

88
function moveTestsFolder(options: Options): void {
99
const { locations, projectRoot } = options;

0 commit comments

Comments
 (0)