-
Notifications
You must be signed in to change notification settings - Fork 1
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
Reorganized utilities and handled multiline comments in JSON #10
Changes from all commits
6683049
7615c84
ca5683c
7d10aff
1cb81b6
568e7e0
c217bc2
894aca2
bc6e490
04d6871
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,8 @@ | |
"test": "npm run test --workspaces --if-present" | ||
}, | ||
"devDependencies": { | ||
"concurrently": "<%= options.packages.addon.dependencies.get('concurrently') ?? '^7.6.0' %>", | ||
"prettier": "<%= options.packages.addon.dependencies.get('prettier') ?? '^2.8.3' %>" | ||
"concurrently": "<%= context.projectRoot.devDependencies['concurrently'] %>", | ||
"prettier": "<%= context.projectRoot.devDependencies['prettier'] %>" | ||
Comment on lines
+23
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed a technical risk (hard-coded latest versions). |
||
} | ||
}<% } else if (options.packageManager.isPnpm) { %>{ | ||
"name": "<%= options.packages.addon.name %>", | ||
|
@@ -45,8 +45,8 @@ | |
"test": "pnpm --filter '*' test" | ||
}, | ||
"devDependencies": { | ||
"concurrently": "<%= options.packages.addon.dependencies.get('concurrently') ?? '^7.6.0' %>", | ||
"prettier": "<%= options.packages.addon.dependencies.get('prettier') ?? '^2.8.3' %>" | ||
"concurrently": "<%= context.projectRoot.devDependencies['concurrently'] %>", | ||
"prettier": "<%= context.projectRoot.devDependencies['prettier'] %>" | ||
} | ||
}<% } else if (options.packageManager.isYarn) { %>{ | ||
"name": "<%= options.packages.addon.name %>", | ||
|
@@ -70,7 +70,7 @@ | |
"test": "yarn workspaces run test" | ||
}, | ||
"devDependencies": { | ||
"concurrently": "<%= options.packages.addon.dependencies.get('concurrently') ?? '^7.6.0' %>", | ||
"prettier": "<%= options.packages.addon.dependencies.get('prettier') ?? '^2.8.3' %>" | ||
"concurrently": "<%= context.projectRoot.devDependencies['concurrently'] %>", | ||
"prettier": "<%= context.projectRoot.devDependencies['prettier'] %>" | ||
} | ||
}<% } %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './blueprints/decide-version.js'; | ||
export * from './blueprints/process-template.js'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
/* https://github.com/ember-cli/ember-cli/blob/v4.9.2/lib/utilities/process-template.js */ | ||
import template from 'lodash.template'; | ||
|
||
export function processTemplate(content, context) { | ||
const options = { | ||
export function processTemplate(file, data) { | ||
const settings = { | ||
Comment on lines
+4
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I renamed the variables so that the words |
||
escape: /<%-([\s\S]+?)%>/g, | ||
evaluate: /<%([\s\S]+?)%>/g, | ||
interpolate: /<%=([\s\S]+?)%>/g, | ||
}; | ||
|
||
return template(content, options)(context); | ||
return template(file, settings)(data); | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,6 @@ | ||
import { | ||
copyFileSync, | ||
existsSync, | ||
mkdirSync, | ||
readdirSync, | ||
renameSync, | ||
rmSync, | ||
writeFileSync, | ||
} from 'node:fs'; | ||
import { dirname, join } from 'node:path'; | ||
|
||
function removeDirectoryIfEmpty({ oldPath, projectRoot }) { | ||
const directories = dirname(oldPath).split('/'); | ||
const depth = directories.length; | ||
|
||
for (let i = 0; i < depth; i++) { | ||
const directory = join(projectRoot, ...directories); | ||
const numFilesLeft = readdirSync(directory).length; | ||
|
||
if (numFilesLeft > 0) { | ||
continue; | ||
} | ||
|
||
rmSync(directory, { recursive: true }); | ||
directories.pop(); | ||
} | ||
} | ||
|
||
export function copyFiles(pathMapping, options) { | ||
const { projectRoot } = options; | ||
|
||
pathMapping.forEach((newPath, oldPath) => { | ||
const oldAbsolutePath = join(projectRoot, oldPath); | ||
|
||
const newAbsolutePath = join(projectRoot, newPath); | ||
const newDirectory = dirname(newAbsolutePath); | ||
|
||
if (!existsSync(newDirectory)) { | ||
mkdirSync(newDirectory, { recursive: true }); | ||
} | ||
|
||
copyFileSync(oldAbsolutePath, newAbsolutePath); | ||
}); | ||
} | ||
|
||
export function createFiles(fileMapping, options) { | ||
const { projectRoot } = options; | ||
|
||
fileMapping.forEach((file, newPath) => { | ||
const newAbsolutePath = join(projectRoot, newPath); | ||
const newDirectory = dirname(newAbsolutePath); | ||
|
||
if (!existsSync(newDirectory)) { | ||
mkdirSync(newDirectory, { recursive: true }); | ||
} | ||
|
||
writeFileSync(newAbsolutePath, file, 'utf8'); | ||
}); | ||
} | ||
|
||
export function moveFiles(pathMapping, options) { | ||
const { projectRoot } = options; | ||
|
||
pathMapping.forEach((newPath, oldPath) => { | ||
const oldAbsolutePath = join(projectRoot, oldPath); | ||
|
||
const newAbsolutePath = join(projectRoot, newPath); | ||
const newDirectory = dirname(newAbsolutePath); | ||
|
||
if (!existsSync(newDirectory)) { | ||
mkdirSync(newDirectory, { recursive: true }); | ||
} | ||
|
||
renameSync(oldAbsolutePath, newAbsolutePath); | ||
removeDirectoryIfEmpty({ oldPath, projectRoot }); | ||
}); | ||
} | ||
|
||
export function removeFiles(pathMapping, options) { | ||
const { projectRoot } = options; | ||
|
||
pathMapping.forEach((newPath, oldPath) => { | ||
const oldAbsolutePath = join(projectRoot, oldPath); | ||
|
||
rmSync(oldAbsolutePath); | ||
removeDirectoryIfEmpty({ oldPath, projectRoot }); | ||
}); | ||
} | ||
export * from './files/copy-files.js'; | ||
export * from './files/create-files.js'; | ||
export * from './files/map-file-paths.js'; | ||
export * from './files/move-files.js'; | ||
export * from './files/remove-directory-if-empty.js'; | ||
export * from './files/remove-files.js'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { copyFileSync, existsSync, mkdirSync } from 'node:fs'; | ||
import { dirname, join } from 'node:path'; | ||
|
||
export function copyFiles(pathMapping, options) { | ||
const { projectRoot } = options; | ||
|
||
pathMapping.forEach((newPath, oldPath) => { | ||
const oldAbsolutePath = join(projectRoot, oldPath); | ||
|
||
const newAbsolutePath = join(projectRoot, newPath); | ||
const newDirectory = dirname(newAbsolutePath); | ||
|
||
if (!existsSync(newDirectory)) { | ||
mkdirSync(newDirectory, { recursive: true }); | ||
} | ||
|
||
copyFileSync(oldAbsolutePath, newAbsolutePath); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove this dependency if we can find another (simple) way to partially update
tsconfig.json
.