@keycloakify/svelte 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/keycloakify-svelte/bin/279.index.js +194 -48
  2. package/keycloakify-svelte/login/DefaultPage.svelte.d.ts +4 -4
  3. package/keycloakify-svelte/login/components/AddRemoveButtonsMultiValuedAttribute.svelte.d.ts +4 -3
  4. package/keycloakify-svelte/login/components/FieldErrors.svelte.d.ts +3 -3
  5. package/keycloakify-svelte/login/components/GroupLabel.svelte.d.ts +4 -4
  6. package/keycloakify-svelte/login/components/InputTag.svelte.d.ts +1 -1
  7. package/keycloakify-svelte/login/components/LogoutOtherSessions.svelte.d.ts +3 -3
  8. package/keycloakify-svelte/login/components/PasswordWrapper.svelte.d.ts +4 -4
  9. package/keycloakify-svelte/login/components/TermsAcceptance.svelte.d.ts +4 -3
  10. package/keycloakify-svelte/login/pages/IdpReviewUserProfile.svelte.d.ts +5 -2
  11. package/keycloakify-svelte/login/pages/LoginUpdateProfile.svelte.d.ts +5 -2
  12. package/keycloakify-svelte/login/pages/Register.svelte.d.ts +5 -2
  13. package/keycloakify-svelte/login/pages/UpdateEmail.svelte.d.ts +5 -2
  14. package/package.json +26 -24
  15. package/src/bin/add-story.ts +117 -0
  16. package/src/bin/core.ts +10 -0
  17. package/src/bin/eject-page.ts +233 -0
  18. package/src/bin/initialize-account-theme/boilerplate/KcContext.ts +11 -0
  19. package/src/bin/initialize-account-theme/boilerplate/KcPage.svelte +28 -0
  20. package/src/bin/initialize-account-theme/boilerplate/KcPageStory.svelte +9 -0
  21. package/src/bin/initialize-account-theme/boilerplate/KcPageStory.ts +22 -0
  22. package/src/bin/initialize-account-theme/boilerplate/i18n.ts +9 -0
  23. package/src/bin/initialize-account-theme/index.ts +1 -0
  24. package/src/bin/initialize-account-theme/initialize-account-theme.ts +87 -0
  25. package/src/bin/initialize-account-theme/updateAccountThemeImplementationInConfig.ts +93 -0
  26. package/src/bin/main.ts +43 -0
  27. package/src/bin/tools/SemVer.ts +107 -0
  28. package/src/bin/tools/String.prototype.replaceAll.ts +31 -0
  29. package/src/bin/tools/crawl.ts +32 -0
  30. package/src/bin/tools/fs.rmSync.ts +34 -0
  31. package/src/bin/tools/getThisCodebaseRootDirPath.ts +22 -0
  32. package/src/bin/tools/kebabCaseToSnakeCase.ts +7 -0
  33. package/src/bin/tools/nodeModulesBinDirPath.ts +38 -0
  34. package/src/bin/tools/readThisNpmPackageVersion.ts +22 -0
  35. package/src/bin/tools/runPrettier.ts +118 -0
  36. package/src/bin/tools/transformCodebase.ts +81 -0
  37. package/src/bin/tools/transformCodebase_async.ts +82 -0
  38. package/src/bin/tsconfig.json +23 -0
  39. package/src/bin/update-kc-gen.ts +153 -0
  40. package/src/tools/useConst.ts +4 -0
  41. package/src/tools/useInsertLinkTags.ts +81 -0
  42. package/src/tools/useInsertScriptTags.ts +110 -0
  43. package/src/tools/useReducer.ts +11 -0
  44. package/src/tools/useSetClassName.ts +18 -0
  45. package/src/tools/useState.ts +8 -0
  46. package/stories/login/KcPage.svelte +10 -10
@@ -0,0 +1,107 @@
1
+ /* eslint-disable @typescript-eslint/no-namespace */
2
+ export type SemVer = {
3
+ major: number;
4
+ minor: number;
5
+ patch: number;
6
+ rc?: number;
7
+ parsedFrom: string;
8
+ };
9
+
10
+ export namespace SemVer {
11
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
12
+ const bumpTypes = ['major', 'minor', 'patch', 'rc', 'no bump'] as const;
13
+
14
+ export type BumpType = (typeof bumpTypes)[number];
15
+
16
+ export function parse(versionStr: string): SemVer {
17
+ const match = versionStr.match(/^v?([0-9]+)\.([0-9]+)(?:\.([0-9]+))?(?:-rc.([0-9]+))?$/);
18
+
19
+ if (!match) {
20
+ throw new Error(`${versionStr} is not a valid semantic version`);
21
+ }
22
+
23
+ const semVer: Omit<SemVer, 'parsedFrom'> = {
24
+ major: parseInt(match[1]),
25
+ minor: parseInt(match[2]),
26
+ patch: (() => {
27
+ const str = match[3];
28
+
29
+ return str === undefined ? 0 : parseInt(str);
30
+ })(),
31
+ ...(() => {
32
+ const str = match[4];
33
+ return str === undefined ? {} : { rc: parseInt(str) };
34
+ })(),
35
+ };
36
+
37
+ const initialStr = stringify(semVer);
38
+
39
+ Object.defineProperty(semVer, 'parsedFrom', {
40
+ enumerable: true,
41
+ get: function () {
42
+ const currentStr = stringify(this);
43
+
44
+ if (currentStr !== initialStr) {
45
+ throw new Error(
46
+ `SemVer.parsedFrom can't be read anymore, the version have been modified from ${initialStr} to ${currentStr}`,
47
+ );
48
+ }
49
+
50
+ return versionStr;
51
+ },
52
+ });
53
+
54
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
+ return semVer as any;
56
+ }
57
+
58
+ export function stringify(v: Omit<SemVer, 'parsedFrom'>): string {
59
+ return `${v.major}.${v.minor}.${v.patch}${v.rc === undefined ? '' : `-rc.${v.rc}`}`;
60
+ }
61
+
62
+ /**
63
+ *
64
+ * v1 < v2 => -1
65
+ * v1 === v2 => 0
66
+ * v1 > v2 => 1
67
+ *
68
+ */
69
+ export function compare(v1: SemVer, v2: SemVer): -1 | 0 | 1 {
70
+ const sign = (diff: number): -1 | 0 | 1 => (diff === 0 ? 0 : diff < 0 ? -1 : 1);
71
+ const noUndefined = (n: number | undefined) => n ?? Infinity;
72
+
73
+ for (const level of ['major', 'minor', 'patch', 'rc'] as const) {
74
+ if (noUndefined(v1[level]) !== noUndefined(v2[level])) {
75
+ return sign(noUndefined(v1[level]) - noUndefined(v2[level]));
76
+ }
77
+ }
78
+
79
+ return 0;
80
+ }
81
+
82
+ /*
83
+ console.log(compare(parse("3.0.0-rc.3"), parse("3.0.0")) === -1 )
84
+ console.log(compare(parse("3.0.0-rc.3"), parse("3.0.0-rc.4")) === -1 )
85
+ console.log(compare(parse("3.0.0-rc.3"), parse("4.0.0")) === -1 )
86
+ */
87
+
88
+ export function bumpType(params: {
89
+ versionBehind: string | SemVer;
90
+ versionAhead: string | SemVer;
91
+ }): BumpType | 'no bump' {
92
+ const versionAhead = typeof params.versionAhead === 'string' ? parse(params.versionAhead) : params.versionAhead;
93
+ const versionBehind = typeof params.versionBehind === 'string' ? parse(params.versionBehind) : params.versionBehind;
94
+
95
+ if (compare(versionBehind, versionAhead) === 1) {
96
+ throw new Error(`Version regression ${stringify(versionBehind)} -> ${stringify(versionAhead)}`);
97
+ }
98
+
99
+ for (const level of ['major', 'minor', 'patch', 'rc'] as const) {
100
+ if (versionBehind[level] !== versionAhead[level]) {
101
+ return level;
102
+ }
103
+ }
104
+
105
+ return 'no bump';
106
+ }
107
+ }
@@ -0,0 +1,31 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ export function replaceAll(string: string, searchValue: string | RegExp, replaceValue: string): string {
3
+ if ((string as any).replaceAll !== undefined) {
4
+ return (string as any).replaceAll(searchValue, replaceValue);
5
+ }
6
+
7
+ // If the searchValue is a string
8
+ if (typeof searchValue === 'string') {
9
+ // Escape special characters in the string to be used in a regex
10
+ const escapedSearchValue = searchValue.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
11
+ const regex = new RegExp(escapedSearchValue, 'g');
12
+
13
+ return string.replace(regex, replaceValue);
14
+ }
15
+
16
+ // If the searchValue is a global RegExp, use it directly
17
+ if (searchValue instanceof RegExp && searchValue.global) {
18
+ return string.replace(searchValue, replaceValue);
19
+ }
20
+
21
+ // If the searchValue is a non-global RegExp, throw an error
22
+ if (searchValue instanceof RegExp) {
23
+ throw new TypeError('replaceAll must be called with a global RegExp');
24
+ }
25
+
26
+ // Convert searchValue to string if it's not a string or RegExp
27
+ const searchString = String(searchValue);
28
+ const regexFromString = new RegExp(searchString.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g');
29
+
30
+ return string.replace(regexFromString, replaceValue);
31
+ }
@@ -0,0 +1,32 @@
1
+ import * as fs from 'fs';
2
+ import { join as pathJoin, relative as pathRelative } from 'path';
3
+
4
+ const crawlRec = (dirPath: string, filePaths: string[]) => {
5
+ for (const basename of fs.readdirSync(dirPath)) {
6
+ const fileOrDirPath = pathJoin(dirPath, basename);
7
+
8
+ if (fs.lstatSync(fileOrDirPath).isDirectory()) {
9
+ crawlRec(fileOrDirPath, filePaths);
10
+
11
+ continue;
12
+ }
13
+
14
+ filePaths.push(fileOrDirPath);
15
+ }
16
+ };
17
+
18
+ /** List all files in a given directory return paths relative to the dir_path */
19
+ export function crawl(params: { dirPath: string; returnedPathsType: 'absolute' | 'relative to dirPath' }): string[] {
20
+ const { dirPath, returnedPathsType } = params;
21
+
22
+ const filePaths: string[] = [];
23
+
24
+ crawlRec(dirPath, filePaths);
25
+
26
+ switch (returnedPathsType) {
27
+ case 'absolute':
28
+ return filePaths;
29
+ case 'relative to dirPath':
30
+ return filePaths.map((filePath) => pathRelative(dirPath, filePath));
31
+ }
32
+ }
@@ -0,0 +1,34 @@
1
+ import * as fs from 'fs';
2
+ import { join as pathJoin } from 'path';
3
+ import { SemVer } from './SemVer';
4
+
5
+ /**
6
+ * Polyfill of fs.rmSync(dirPath, { "recursive": true })
7
+ * For older version of Node
8
+ */
9
+ export function rmSync(dirPath: string, options: { recursive: true; force?: true }) {
10
+ if (SemVer.compare(SemVer.parse(process.version), SemVer.parse('14.14.0')) > 0) {
11
+ fs.rmSync(dirPath, options);
12
+ return;
13
+ }
14
+
15
+ const { force = true } = options;
16
+
17
+ if (force && !fs.existsSync(dirPath)) {
18
+ return;
19
+ }
20
+
21
+ const removeDir_rec = (dirPath: string) =>
22
+ fs.readdirSync(dirPath).forEach((basename) => {
23
+ const fileOrDirPath = pathJoin(dirPath, basename);
24
+
25
+ if (fs.lstatSync(fileOrDirPath).isDirectory()) {
26
+ removeDir_rec(fileOrDirPath);
27
+ return;
28
+ } else {
29
+ fs.unlinkSync(fileOrDirPath);
30
+ }
31
+ });
32
+
33
+ removeDir_rec(dirPath);
34
+ }
@@ -0,0 +1,22 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import * as url from 'url';
4
+
5
+ const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
6
+
7
+ function getThisCodebaseRootDirPath_rec(dirPath: string): string {
8
+ if (!dirPath.includes('/bin') && fs.existsSync(path.join(dirPath, 'package.json'))) {
9
+ return dirPath;
10
+ }
11
+ return getThisCodebaseRootDirPath_rec(path.join(dirPath, '..'));
12
+ }
13
+
14
+ let result: string | undefined = undefined;
15
+
16
+ export function getThisCodebaseRootDirPath(): string {
17
+ if (result !== undefined) {
18
+ return result;
19
+ }
20
+
21
+ return (result = getThisCodebaseRootDirPath_rec(__dirname));
22
+ }
@@ -0,0 +1,7 @@
1
+ import { capitalize } from 'tsafe/capitalize';
2
+
3
+ export function kebabCaseToCamelCase(kebabCaseString: string): string {
4
+ const [first, ...rest] = kebabCaseString.split('-');
5
+
6
+ return [first, ...rest.map(capitalize)].join('');
7
+ }
@@ -0,0 +1,38 @@
1
+ import { sep as pathSep } from 'path';
2
+
3
+ let cache: string | undefined = undefined;
4
+
5
+ export function getNodeModulesBinDirPath() {
6
+ if (cache !== undefined) {
7
+ return cache;
8
+ }
9
+
10
+ const binPath = process.argv[1];
11
+
12
+ const segments: string[] = ['.bin'];
13
+
14
+ let foundNodeModules = false;
15
+
16
+ for (const segment of binPath.split(pathSep).reverse()) {
17
+ skip_segment: {
18
+ if (foundNodeModules) {
19
+ break skip_segment;
20
+ }
21
+
22
+ if (segment === 'node_modules') {
23
+ foundNodeModules = true;
24
+ break skip_segment;
25
+ }
26
+
27
+ continue;
28
+ }
29
+
30
+ segments.unshift(segment);
31
+ }
32
+
33
+ const nodeModulesBinDirPath = segments.join(pathSep);
34
+
35
+ cache = nodeModulesBinDirPath;
36
+
37
+ return nodeModulesBinDirPath;
38
+ }
@@ -0,0 +1,22 @@
1
+ import * as fs from 'fs';
2
+ import { join as pathJoin } from 'path';
3
+ import { assert } from 'tsafe/assert';
4
+ import { getThisCodebaseRootDirPath } from './getThisCodebaseRootDirPath';
5
+
6
+ let cache: string | undefined = undefined;
7
+
8
+ export function readThisNpmPackageVersion(): string {
9
+ if (cache !== undefined) {
10
+ return cache;
11
+ }
12
+
13
+ const version = JSON.parse(fs.readFileSync(pathJoin(getThisCodebaseRootDirPath(), 'package.json')).toString('utf8'))[
14
+ 'version'
15
+ ];
16
+
17
+ assert(typeof version === 'string');
18
+
19
+ cache = version;
20
+
21
+ return version;
22
+ }
@@ -0,0 +1,118 @@
1
+ import chalk from 'chalk';
2
+ import * as crypto from 'crypto';
3
+ import * as fsPr from 'fs/promises';
4
+ import { join as pathJoin, resolve as pathResolve } from 'path';
5
+ import { assert } from 'tsafe/assert';
6
+ import { id } from 'tsafe/id';
7
+ import { is } from 'tsafe/is';
8
+ import { symToStr } from 'tsafe/symToStr';
9
+ import { getNodeModulesBinDirPath } from './nodeModulesBinDirPath';
10
+ import { readThisNpmPackageVersion } from './readThisNpmPackageVersion';
11
+
12
+ getIsPrettierAvailable.cache = id<boolean | undefined>(undefined);
13
+
14
+ export async function getIsPrettierAvailable(): Promise<boolean> {
15
+ if (getIsPrettierAvailable.cache !== undefined) {
16
+ return getIsPrettierAvailable.cache;
17
+ }
18
+
19
+ const nodeModulesBinDirPath = getNodeModulesBinDirPath();
20
+
21
+ const prettierBinPath = pathJoin(nodeModulesBinDirPath, 'prettier');
22
+
23
+ const stats = await fsPr.stat(prettierBinPath).catch(() => undefined);
24
+
25
+ const isPrettierAvailable = stats?.isFile() ?? false;
26
+
27
+ getIsPrettierAvailable.cache = isPrettierAvailable;
28
+
29
+ return isPrettierAvailable;
30
+ }
31
+
32
+ type PrettierAndConfigHash = {
33
+ prettier: typeof import('prettier');
34
+ configHash: string;
35
+ };
36
+
37
+ getPrettier.cache = id<PrettierAndConfigHash | undefined>(undefined);
38
+
39
+ export async function getPrettier(): Promise<PrettierAndConfigHash> {
40
+ assert(getIsPrettierAvailable());
41
+
42
+ if (getPrettier.cache !== undefined) {
43
+ return getPrettier.cache;
44
+ }
45
+
46
+ let prettier = id<typeof import('prettier') | undefined>(undefined);
47
+
48
+ import_prettier: {
49
+ // NOTE: When module is linked we want to make sure we import the correct version
50
+ // of prettier, that is the one of the project, not the one of this repo.
51
+ // So we do a sketchy eval to bypass ncc.
52
+ // We make sure to only do that when linking, otherwise we import properly.
53
+ if (readThisNpmPackageVersion().startsWith('0.0.0')) {
54
+ eval(
55
+ `${symToStr({ prettier })} = require("${pathResolve(pathJoin(getNodeModulesBinDirPath(), '..', 'prettier'))}")`,
56
+ );
57
+
58
+ assert(!is<undefined>(prettier));
59
+
60
+ break import_prettier;
61
+ }
62
+
63
+ prettier = await import('prettier');
64
+ }
65
+
66
+ const configHash = await (async () => {
67
+ const configFilePath = await prettier.resolveConfigFile(pathJoin(getNodeModulesBinDirPath(), '..'));
68
+
69
+ if (configFilePath === null) {
70
+ return '';
71
+ }
72
+
73
+ const data = await fsPr.readFile(configFilePath);
74
+
75
+ return crypto.createHash('sha256').update(data).digest('hex');
76
+ })();
77
+
78
+ const prettierAndConfig: PrettierAndConfigHash = {
79
+ prettier,
80
+ configHash,
81
+ };
82
+
83
+ getPrettier.cache = prettierAndConfig;
84
+
85
+ return prettierAndConfig;
86
+ }
87
+
88
+ export async function runPrettier(params: { sourceCode: string; filePath: string }): Promise<string> {
89
+ const { sourceCode, filePath } = params;
90
+
91
+ let formattedSourceCode: string;
92
+
93
+ try {
94
+ const { prettier } = await getPrettier();
95
+
96
+ const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
97
+ resolveConfig: true,
98
+ });
99
+
100
+ if (ignored) {
101
+ return sourceCode;
102
+ }
103
+
104
+ const config = await prettier.resolveConfig(filePath);
105
+
106
+ formattedSourceCode = await prettier.format(sourceCode, {
107
+ ...config,
108
+ filePath,
109
+ parser: inferredParser ?? undefined,
110
+ });
111
+ } catch (error) {
112
+ console.log(chalk.red(`You probably need to upgrade the version of prettier in your project`));
113
+
114
+ throw error;
115
+ }
116
+
117
+ return formattedSourceCode;
118
+ }
@@ -0,0 +1,81 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import { rmSync } from '../tools/fs.rmSync';
4
+ import { crawl } from './crawl';
5
+
6
+ type TransformSourceCode = (params: { sourceCode: Buffer; filePath: string; fileRelativePath: string }) =>
7
+ | {
8
+ modifiedSourceCode: Buffer;
9
+ newFileName?: string;
10
+ }
11
+ | undefined;
12
+
13
+ /**
14
+ * Apply a transformation function to every file of directory
15
+ * If source and destination are the same this function can be used to apply the transformation in place
16
+ * like filtering out some files or modifying them.
17
+ * */
18
+ export function transformCodebase(params: {
19
+ srcDirPath: string;
20
+ destDirPath: string;
21
+ transformSourceCode?: TransformSourceCode;
22
+ }) {
23
+ const { srcDirPath, transformSourceCode } = params;
24
+
25
+ const isTargetSameAsSource = path.relative(srcDirPath, params.destDirPath) === '';
26
+
27
+ const destDirPath = isTargetSameAsSource
28
+ ? path.join(srcDirPath, '..', 'tmp_xOsPdkPsTdzPs34sOkHs')
29
+ : params.destDirPath;
30
+
31
+ fs.mkdirSync(destDirPath, {
32
+ recursive: true,
33
+ });
34
+
35
+ for (const fileRelativePath of crawl({
36
+ dirPath: srcDirPath,
37
+ returnedPathsType: 'relative to dirPath',
38
+ })) {
39
+ const filePath = path.join(srcDirPath, fileRelativePath);
40
+ const destFilePath = path.join(destDirPath, fileRelativePath);
41
+
42
+ // NOTE: Optimization, if we don't need to transform the file, just copy
43
+ // it using the lower level implementation.
44
+ if (transformSourceCode === undefined) {
45
+ fs.mkdirSync(path.dirname(destFilePath), {
46
+ recursive: true,
47
+ });
48
+
49
+ fs.copyFileSync(filePath, destFilePath);
50
+
51
+ continue;
52
+ }
53
+
54
+ const transformSourceCodeResult = transformSourceCode({
55
+ sourceCode: fs.readFileSync(filePath),
56
+ filePath,
57
+ fileRelativePath,
58
+ });
59
+
60
+ if (transformSourceCodeResult === undefined) {
61
+ continue;
62
+ }
63
+
64
+ fs.mkdirSync(path.dirname(destFilePath), {
65
+ recursive: true,
66
+ });
67
+
68
+ const { newFileName, modifiedSourceCode } = transformSourceCodeResult;
69
+
70
+ fs.writeFileSync(
71
+ path.join(path.dirname(destFilePath), newFileName ?? path.basename(destFilePath)),
72
+ modifiedSourceCode,
73
+ );
74
+ }
75
+
76
+ if (isTargetSameAsSource) {
77
+ rmSync(srcDirPath, { recursive: true });
78
+
79
+ fs.renameSync(destDirPath, srcDirPath);
80
+ }
81
+ }
@@ -0,0 +1,82 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import { rmSync } from '../tools/fs.rmSync';
4
+ import { crawl } from './crawl';
5
+
6
+ type TransformSourceCode = (params: { sourceCode: Buffer; filePath: string; fileRelativePath: string }) => Promise<
7
+ | {
8
+ modifiedSourceCode: Buffer;
9
+ newFileName?: string;
10
+ }
11
+ | undefined
12
+ >;
13
+
14
+ /**
15
+ * Apply a transformation function to every file of directory
16
+ * If source and destination are the same this function can be used to apply the transformation in place
17
+ * like filtering out some files or modifying them.
18
+ * */
19
+ export async function transformCodebase(params: {
20
+ srcDirPath: string;
21
+ destDirPath: string;
22
+ transformSourceCode?: TransformSourceCode;
23
+ }) {
24
+ const { srcDirPath, transformSourceCode } = params;
25
+
26
+ const isTargetSameAsSource = path.relative(srcDirPath, params.destDirPath) === '';
27
+
28
+ const destDirPath = isTargetSameAsSource
29
+ ? path.join(srcDirPath, '..', 'tmp_xOsPdkPsTdzPs34sOkHs')
30
+ : params.destDirPath;
31
+
32
+ fs.mkdirSync(destDirPath, {
33
+ recursive: true,
34
+ });
35
+
36
+ for (const fileRelativePath of crawl({
37
+ dirPath: srcDirPath,
38
+ returnedPathsType: 'relative to dirPath',
39
+ })) {
40
+ const filePath = path.join(srcDirPath, fileRelativePath);
41
+ const destFilePath = path.join(destDirPath, fileRelativePath);
42
+
43
+ // NOTE: Optimization, if we don't need to transform the file, just copy
44
+ // it using the lower level implementation.
45
+ if (transformSourceCode === undefined) {
46
+ fs.mkdirSync(path.dirname(destFilePath), {
47
+ recursive: true,
48
+ });
49
+
50
+ fs.copyFileSync(filePath, destFilePath);
51
+
52
+ continue;
53
+ }
54
+
55
+ const transformSourceCodeResult = await transformSourceCode({
56
+ sourceCode: fs.readFileSync(filePath),
57
+ filePath,
58
+ fileRelativePath,
59
+ });
60
+
61
+ if (transformSourceCodeResult === undefined) {
62
+ continue;
63
+ }
64
+
65
+ fs.mkdirSync(path.dirname(destFilePath), {
66
+ recursive: true,
67
+ });
68
+
69
+ const { newFileName, modifiedSourceCode } = transformSourceCodeResult;
70
+
71
+ fs.writeFileSync(
72
+ path.join(path.dirname(destFilePath), newFileName ?? path.basename(destFilePath)),
73
+ modifiedSourceCode,
74
+ );
75
+ }
76
+
77
+ if (isTargetSameAsSource) {
78
+ rmSync(srcDirPath, { recursive: true });
79
+
80
+ fs.renameSync(destDirPath, srcDirPath);
81
+ }
82
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "compilerOptions": {
3
+ "sourceMap": false,
4
+ "newLine": "LF",
5
+ "noUnusedLocals": true,
6
+ "noUnusedParameters": true,
7
+ "strict": true,
8
+ "downlevelIteration": true,
9
+ "noFallthroughCasesInSwitch": true,
10
+ "composite": true,
11
+ "rootDir": ".",
12
+ "module": "ES2020",
13
+ "target": "ES2017",
14
+ "esModuleInterop": true,
15
+ "lib": ["es2015", "ES2019.Object"],
16
+ "moduleResolution": "node"
17
+ },
18
+ "include": ["**/*.ts"],
19
+ "exclude": ["initialize-account-theme/boilerplate"],
20
+ "ts-node": {
21
+ "esm": true
22
+ }
23
+ }