ember-cli 6.7.0-beta.1 → 6.8.0-alpha.2

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 (27) hide show
  1. package/CHANGELOG.md +122 -17
  2. package/RELEASE.md +31 -5
  3. package/docs/build/data.json +1 -1
  4. package/lib/commands/init.js +28 -2
  5. package/lib/commands/new.js +19 -1
  6. package/lib/debug/deprecations.js +19 -0
  7. package/package.json +8 -9
  8. package/packages/addon-blueprint/index.js +1 -1
  9. package/packages/addon-blueprint/package.json +4 -4
  10. package/packages/app-blueprint/files/_js_eslint.config.mjs +3 -0
  11. package/packages/app-blueprint/files/_ts_eslint.config.mjs +6 -1
  12. package/packages/app-blueprint/files/config/ember-cli-update.json +1 -3
  13. package/packages/app-blueprint/files/package.json +15 -15
  14. package/packages/app-blueprint/index.js +1 -1
  15. package/packages/app-blueprint/package.json +4 -4
  16. package/packages/blueprint-blueprint/files/blueprints/__name__/files/.gitkeep +0 -0
  17. package/packages/blueprint-blueprint/files/blueprints/__name__/index.js +16 -0
  18. package/packages/blueprint-blueprint/index.js +5 -0
  19. package/packages/blueprint-blueprint/package.json +9 -0
  20. package/packages/blueprint-model/package.json +18 -0
  21. package/packages/blueprint-model/utilities/directory-for-package-name.js +31 -0
  22. package/packages/blueprint-model/utilities/edit-file-diff.js +64 -0
  23. package/packages/blueprint-model/utilities/experiments.js +54 -0
  24. package/packages/blueprint-model/utilities/file-info.js +170 -0
  25. package/packages/blueprint-model/utilities/open-editor.js +44 -0
  26. package/packages/blueprint-model/utilities/prepend-emoji.js +12 -0
  27. package/packages/blueprint-model/utilities/process-template.js +10 -0
package/CHANGELOG.md CHANGED
@@ -1,43 +1,146 @@
1
1
  # ember-cli Changelog
2
2
 
3
- ## Release (2025-08-01)
3
+ ## Release (2025-09-01)
4
4
 
5
- * @ember-tooling/classic-build-addon-blueprint 6.7.0-beta.1 (minor)
6
- * @ember-tooling/classic-build-app-blueprint 6.7.0-beta.1 (minor)
7
- * ember-cli 6.7.0-beta.1 (patch)
5
+ * @ember-tooling/classic-build-addon-blueprint 6.8.0-alpha.2 (minor)
6
+ * @ember-tooling/classic-build-app-blueprint 6.8.0-alpha.2 (minor)
7
+ * ember-cli 6.8.0-alpha.2 (patch)
8
+
9
+ #### :rocket: Enhancement
10
+ * `@ember-tooling/classic-build-addon-blueprint`, `@ember-tooling/classic-build-app-blueprint`
11
+ * [#10791](https://github.com/ember-cli/ember-cli/pull/10791) update the format of the ember-cli-update.json ([@mansona](https://github.com/mansona))
12
+ * Other
13
+ * [#10785](https://github.com/ember-cli/ember-cli/pull/10785) Depracate passing filenames and globs to `init` ([@pichfl](https://github.com/pichfl))
14
+ * [#10776](https://github.com/ember-cli/ember-cli/pull/10776) Add deprecation warning for the `--embroider` argument ([@pichfl](https://github.com/pichfl))
15
+
16
+ #### :bug: Bug Fix
17
+ * Other
18
+ * [#10782](https://github.com/ember-cli/ember-cli/pull/10782) update heimdall-fs-monitor ([@mansona](https://github.com/mansona))
19
+ * `@ember-tooling/classic-build-app-blueprint`
20
+ * [#10707](https://github.com/ember-cli/ember-cli/pull/10707) Enabled recommended configs from eslint-plugin-n and eslint-plugin-qunit ([@ijlee2](https://github.com/ijlee2))
21
+
22
+ #### :house: Internal
23
+ * [#10790](https://github.com/ember-cli/ember-cli/pull/10790) Reorganize tests for `new` and `addon` commands ([@pichfl](https://github.com/pichfl))
24
+ * [#10783](https://github.com/ember-cli/ember-cli/pull/10783) remove unused changelog script ([@mansona](https://github.com/mansona))
25
+ * [#10764](https://github.com/ember-cli/ember-cli/pull/10764) fix double CI run on release-plan PR ([@mansona](https://github.com/mansona))
26
+ * [#10750](https://github.com/ember-cli/ember-cli/pull/10750) Add more notes to the Release.md ([@mansona](https://github.com/mansona))
27
+
28
+ #### Committers: 3
29
+ - Chris Manson ([@mansona](https://github.com/mansona))
30
+ - Florian Pichler ([@pichfl](https://github.com/pichfl))
31
+ - Isaac Lee ([@ijlee2](https://github.com/ijlee2))
32
+
33
+ ## Release (2025-08-02)
34
+
35
+ * @ember-tooling/classic-build-addon-blueprint 6.8.0-alpha.1 (minor)
36
+ * @ember-tooling/classic-build-app-blueprint 6.8.0-alpha.1 (minor)
37
+ * ember-cli 6.8.0-alpha.1 (patch)
8
38
 
9
39
  #### :rocket: Enhancement
10
40
  * `@ember-tooling/classic-build-addon-blueprint`, `@ember-tooling/classic-build-app-blueprint`
11
41
  * [#10755](https://github.com/ember-cli/ember-cli/pull/10755) Prepare 6.7-beta ([@mansona](https://github.com/mansona))
42
+ * Other
43
+ * [#10751](https://github.com/ember-cli/ember-cli/pull/10751) [BETA BACKPORT] Backport drop node 18 ([@mansona](https://github.com/mansona))
44
+
45
+ #### :house: Internal
46
+ * `@ember-tooling/classic-build-addon-blueprint`, `@ember-tooling/classic-build-app-blueprint`
47
+ * [#10763](https://github.com/ember-cli/ember-cli/pull/10763) Prepare 6.8-alpha ([@mansona](https://github.com/mansona))
48
+ * [#10754](https://github.com/ember-cli/ember-cli/pull/10754) Prepare Beta Release ([@github-actions[bot]](https://github.com/apps/github-actions))
49
+ * Other
50
+ * [#10761](https://github.com/ember-cli/ember-cli/pull/10761) update release-plan ([@mansona](https://github.com/mansona))
51
+
52
+ #### Committers: 2
53
+ - Chris Manson ([@mansona](https://github.com/mansona))
54
+ - [@github-actions[bot]](https://github.com/apps/github-actions)
55
+
56
+ ## Release (2025-07-26)
57
+
58
+ * @ember-tooling/classic-build-addon-blueprint 6.7.0-alpha.4 (minor)
59
+ * @ember-tooling/classic-build-app-blueprint 6.7.0-alpha.4 (minor)
60
+ * ember-cli 6.7.0-alpha.4 (patch)
61
+
62
+ #### :rocket: Enhancement
63
+ * `@ember-tooling/classic-build-addon-blueprint`, `@ember-tooling/classic-build-app-blueprint`
64
+ * [#10742](https://github.com/ember-cli/ember-cli/pull/10742) Drop node 18, add node 24 ([@NullVoxPopuli](https://github.com/NullVoxPopuli))
65
+
66
+ #### :bug: Bug Fix
67
+ * `@ember-tooling/classic-build-addon-blueprint`, `@ember-tooling/classic-build-app-blueprint`
12
68
  * [#10742](https://github.com/ember-cli/ember-cli/pull/10742) Drop node 18, add node 24 ([@NullVoxPopuli](https://github.com/NullVoxPopuli))
13
69
 
14
70
  #### :memo: Documentation
15
- * [#10724](https://github.com/ember-cli/ember-cli/pull/10724) Update RELEASE.md to fully document new release-plan setup ([@mansona](https://github.com/mansona))
71
+ * `@ember-tooling/classic-build-addon-blueprint`, `@ember-tooling/classic-build-app-blueprint`
72
+ * [#10742](https://github.com/ember-cli/ember-cli/pull/10742) Drop node 18, add node 24 ([@NullVoxPopuli](https://github.com/NullVoxPopuli))
73
+
74
+ #### :house: Internal
75
+ * [#10748](https://github.com/ember-cli/ember-cli/pull/10748) update blueprint version of ember-cli as part of release plan ([@mansona](https://github.com/mansona))
76
+ * [#10747](https://github.com/ember-cli/ember-cli/pull/10747) only use the PAT for the PR creation in release-plan ([@mansona](https://github.com/mansona))
77
+ * [#10744](https://github.com/ember-cli/ember-cli/pull/10744) run tests on the release-plan PR ([@mansona](https://github.com/mansona))
78
+
79
+ #### Committers: 2
80
+ - Chris Manson ([@mansona](https://github.com/mansona))
81
+ - [@NullVoxPopuli](https://github.com/NullVoxPopuli)
82
+
83
+ ## Release (2025-06-30)
84
+
85
+ * @ember-tooling/classic-build-addon-blueprint 6.7.0-alpha.3 (patch)
86
+ * @ember-tooling/classic-build-app-blueprint 6.7.0-alpha.3 (patch)
87
+ * @ember-tooling/blueprint-blueprint 0.0.2 (patch)
88
+ * @ember-tooling/blueprint-model 0.0.2 (patch)
89
+ * ember-cli 6.7.0-alpha.3 (patch)
90
+
91
+ #### :house: Internal
92
+ * `@ember-tooling/classic-build-addon-blueprint`, `@ember-tooling/classic-build-app-blueprint`, `@ember-tooling/blueprint-blueprint`, `@ember-tooling/blueprint-model`
93
+ * [#10738](https://github.com/ember-cli/ember-cli/pull/10738) add a repository for each of the packages ([@mansona](https://github.com/mansona))
94
+
95
+ #### Committers: 1
96
+ - Chris Manson ([@mansona](https://github.com/mansona))
97
+
98
+ ## Release (2025-06-30)
99
+
100
+ * @ember-tooling/classic-build-addon-blueprint 6.7.0-alpha.2 (patch)
101
+ * @ember-tooling/classic-build-app-blueprint 6.7.0-alpha.2 (patch)
102
+ * @ember-tooling/blueprint-blueprint 0.0.1 (patch)
103
+ * @ember-tooling/blueprint-model 0.0.1 (patch)
104
+ * ember-cli 6.7.0-alpha.2 (patch)
16
105
 
17
106
  #### :house: Internal
18
107
  * Other
19
- * [#10761](https://github.com/ember-cli/ember-cli/pull/10761) update release-plan ([@mansona](https://github.com/mansona))
20
- * [#10748](https://github.com/ember-cli/ember-cli/pull/10748) update blueprint version of ember-cli as part of release plan ([@mansona](https://github.com/mansona))
21
- * [#10747](https://github.com/ember-cli/ember-cli/pull/10747) only use the PAT for the PR creation in release-plan ([@mansona](https://github.com/mansona))
22
- * [#10744](https://github.com/ember-cli/ember-cli/pull/10744) run tests on the release-plan PR ([@mansona](https://github.com/mansona))
23
108
  * [#10735](https://github.com/ember-cli/ember-cli/pull/10735) remove unnecessary project override ([@mansona](https://github.com/mansona))
24
- * `@ember-tooling/classic-build-addon-blueprint`, `@ember-tooling/classic-build-app-blueprint`
25
- * [#10738](https://github.com/ember-cli/ember-cli/pull/10738) add a repository for each of the packages ([@mansona](https://github.com/mansona))
109
+ * `@ember-tooling/classic-build-addon-blueprint`, `@ember-tooling/classic-build-app-blueprint`, `@ember-tooling/blueprint-blueprint`, `@ember-tooling/blueprint-model`
26
110
  * [#10736](https://github.com/ember-cli/ember-cli/pull/10736) update all sub-packages to have the @ember-tooling prefix ([@mansona](https://github.com/mansona))
27
111
  * [#10671](https://github.com/ember-cli/ember-cli/pull/10671) Implement the built in app, addon, and blueprint blueprints by package lookup ([@mansona](https://github.com/mansona))
28
112
 
29
- #### Committers: 2
113
+ #### Committers: 1
30
114
  - Chris Manson ([@mansona](https://github.com/mansona))
31
- - [@NullVoxPopuli](https://github.com/NullVoxPopuli)
32
115
 
33
- ## Release (2025-07-29)
116
+ ## Release (2025-06-16)
117
+
118
+ * ember-cli 6.7.0-alpha.1 (minor)
119
+
120
+ #### :rocket: Enhancement
121
+ * `ember-cli`
122
+ * [#10705](https://github.com/ember-cli/ember-cli/pull/10705) add `--strict` flag for new app and addon generation ([@mansona](https://github.com/mansona))
34
123
 
35
- * ember-cli 6.6.0 (minor)
124
+ #### :memo: Documentation
125
+ * `ember-cli`
126
+ * [#10724](https://github.com/ember-cli/ember-cli/pull/10724) Update RELEASE.md to fully document new release-plan setup ([@mansona](https://github.com/mansona))
127
+
128
+ #### :house: Internal
129
+ * `ember-cli`
130
+ * [#10731](https://github.com/ember-cli/ember-cli/pull/10731) Prepare Alpha 6.7.0 ([@mansona](https://github.com/mansona))
131
+ * [#10728](https://github.com/ember-cli/ember-cli/pull/10728) Prepare Beta 6.6.0 ([@mansona](https://github.com/mansona))
132
+ * [#10726](https://github.com/ember-cli/ember-cli/pull/10726) use patched github-changelog for properly rolling up beta changelog ([@mansona](https://github.com/mansona))
133
+ * [#10717](https://github.com/ember-cli/ember-cli/pull/10717) pass --publish-branch to release-plan publish ([@mansona](https://github.com/mansona))
134
+
135
+ #### Committers: 1
136
+ - Chris Manson ([@mansona](https://github.com/mansona))
137
+
138
+ ## Release (2025-06-16)
139
+
140
+ * ember-cli 6.6.0-beta.1 (minor)
36
141
 
37
142
  #### :rocket: Enhancement
38
143
  * `ember-cli`
39
- * [#10749](https://github.com/ember-cli/ember-cli/pull/10749) Update all dependencies for 6.6 release ([@mansona](https://github.com/mansona))
40
- * [#10751](https://github.com/ember-cli/ember-cli/pull/10751) [BETA BACKPORT] Backport drop node 18 ([@mansona](https://github.com/mansona))
41
144
  * [#10701](https://github.com/ember-cli/ember-cli/pull/10701) [ENHANCEMENT] Support Bun ([@hexadecy](https://github.com/hexadecy))
42
145
  * [#10664](https://github.com/ember-cli/ember-cli/pull/10664) [ENHANCEMENT] Remove ember-fetch ([@NullVoxPopuli](https://github.com/NullVoxPopuli))
43
146
 
@@ -48,6 +151,8 @@
48
151
 
49
152
  #### :house: Internal
50
153
  * `ember-cli`
154
+ * [#10728](https://github.com/ember-cli/ember-cli/pull/10728) Prepare Beta 6.6.0 ([@mansona](https://github.com/mansona))
155
+ * [#10726](https://github.com/ember-cli/ember-cli/pull/10726) use patched github-changelog for properly rolling up beta changelog ([@mansona](https://github.com/mansona))
51
156
  * [#10699](https://github.com/ember-cli/ember-cli/pull/10699) Start using release-plan for releasing ember-cli ([@mansona](https://github.com/mansona))
52
157
  * [#10670](https://github.com/ember-cli/ember-cli/pull/10670) testing: don't generate temp directories in the repo ([@mansona](https://github.com/mansona))
53
158
 
package/RELEASE.md CHANGED
@@ -16,12 +16,19 @@ During the release week each of the versions are effectively "promoted" i.e. the
16
16
 
17
17
  The release process during release week should look like this:
18
18
 
19
+ - Merge any outstanding `Prepare Alpha Release` branches
19
20
  - Do an intial stable release from the `release` branch
20
21
  - Merge `release` into `beta`
21
22
  - Do a `beta` release
22
23
  - Merge `beta` into `master`
23
24
  - Do an `alpha` release
24
25
 
26
+ ### Merge any outstanding `Prepare Alpha Release` branches
27
+
28
+ This makes sure that you are starting from a "clean slate" before doing any other releases. This will make each of the following steps easier to follow.
29
+
30
+ You can use [this saved search](https://github.com/ember-cli/ember-cli/pulls?q=is%3Apr+is%3Aopen+Prepare) to find any outstanding `Prepare Release` branches.
31
+
25
32
 
26
33
  ### Initial Stable Release from the `release` branch
27
34
 
@@ -31,7 +38,11 @@ The release process during release week should look like this:
31
38
  - Merge `origin/beta` into the release branch
32
39
  - `git merge origin/beta --no-ff`
33
40
  - **make sure to not update the .release-plan file** this should only ever be changed by the release-plan github scripts
41
+ - **make sure to not update the .github/workflows/plan-release.yml file** this should still plan a stable release
42
+ - **make sure to not update the .github/workflows/publish.yml file** this should still publish a stable release
43
+ - **make sure to not update the CHANGELOG.md file** so as not to include the beta or alpha changelogs in the next release
34
44
  - make sure to not update the version in the package.json during this step, this will be release-plan's job
45
+ - make sure to not add the `release-plan` config section to the package.json during this step. We are releasing a real release so we don't want to configure release-plan to do a pre-release.
35
46
  - Update blueprint dependencies to latest
36
47
 
37
48
  ```
@@ -39,9 +50,9 @@ node ./dev/update-blueprint-dependencies.js --ember-source=latest --ember-data=l
39
50
  ```
40
51
 
41
52
  - commit this update `git commit -am "update blueprint dependencies to latest"`
42
- - push and open a PR targeting `release`
53
+ - push and open a PR targeting `release` with a PR title like `Update all dependencies for 6.4 release`
43
54
  - mark this PR as an `enhancement` if it is a minor release
44
- - check that everything is ok
55
+ - check that everything is ok (i.e. that CI has run correctly and that you have the changes you expect)
45
56
  - merge branch
46
57
  - check that the `Prepare Release` PR has been correctly opened by `release-plan`
47
58
  - Merge the `Prepare Release` branch when you are ready to release
@@ -53,9 +64,18 @@ node ./dev/update-blueprint-dependencies.js --ember-source=latest --ember-data=l
53
64
  - create a new branch to merge `release` into `beta` e.g. `git checkout --no-track -b merge-release origin/beta`
54
65
  - merge release into this new branch e.g. `git merge origin/release --no-ff`
55
66
  - **make sure to not update the .release-plan file** this should only ever be changed by the release-plan github scripts
67
+ - **make sure to not update any .github/workflows/plan-release.yml file** this should still plan a beta release
68
+ - **make sure to not update any .github/workflows/publish.yml file** this should still publish a beta release
69
+ - make sure to not update the version in the package.json during this step, that step comes later
70
+ - make sure to not remove the `release-plan` config section to the `package.json`, `packages/addon-blueprint/package.json`, or `packages/app-blueprint/package.json`, during this step.
56
71
  - merge master into this new branch too e.g. `git merge origin/master --no-ff`
57
72
  - **make sure to not update the .release-plan file** this should only ever be changed by the release-plan github scripts
73
+ - **make sure to not update the CHANGELOG.md file** in this step. It should match the changelog on `origin/release` at this stage.
58
74
  - update the alpha version in package.json to be a beta i.e. if the incoming merge is `"version": "6.6.0-alpha.3",` update it to `"version": "6.6.0-beta.0",`
75
+ - update the alpha version in `packages/addon-blueprint/package.json` to be a beta
76
+ - update the alpha version in `packages/app-blueprint/package.json` to be a beta
77
+ - make sure not to update the `release-plan` config in `package.json`, `packages/addon-blueprint/package.json`, or `packages/app-blueprint/package.json`
78
+ - update the `ember-cli` reference in `packages/app-blueprint/files/package.json` to be the same as the version you just put in the top level package.json
59
79
  - Update blueprint dependencies to beta
60
80
 
61
81
  ```
@@ -63,7 +83,7 @@ node ./dev/update-blueprint-dependencies.js --ember-source=beta --ember-data=bet
63
83
  ```
64
84
 
65
85
  - commit this update `git commit -am "update blueprint dependencies to beta"`
66
- - push and open a PR targeting `beta`
86
+ - push and open a PR targeting `beta` with a PR title like `Prepare 6.5-beta`
67
87
  - mark this PR as an `enchancement` if the next beta is a minor release
68
88
  - check that everything is ok i.e. CI passes
69
89
  - merge the `merge-release` branch into `beta` in GitHub
@@ -79,8 +99,14 @@ node ./dev/update-blueprint-dependencies.js --ember-source=beta --ember-data=bet
79
99
  - create a new branch to merge `beta` into `master` e.g. `git checkout --no-track -b merge-beta origin/master`
80
100
  - merge beta into this new branch e.g. `git merge origin/beta --no-ff`
81
101
  - **make sure to not update the .release-plan file** this should only ever be changed by the release-plan github scripts
82
- - manually update the version in pacakge.json to be the next alpha.
102
+ - make sure to not update the `release-plan` config section to the `package.json`, `packages/addon-blueprint/package.json`, or `packages/app-blueprint/package.json`, during this step.
103
+ - **make sure to not update any .github/workflows/plan-release.yml file** this should still plan a beta release
104
+ - **make sure to not update any .github/workflows/publish.yml file** this should still publish a beta release
105
+ - **make sure to not update the CHANGELOG.md file** in this step.
106
+ - manually update the version in package.json to be the next alpha.
83
107
  - e.g. if the current alpha is `"version": "6.6.0-alpha.3",` update it to be `"version": "6.7.0-alpha.0",`
108
+ - manually update the alpha version in `packages/addon-blueprint/package.json` to be the same alpha
109
+ - manually update the alpha version in `packages/app-blueprint/package.json` to be the same alpha
84
110
  - commit this change to the version in package.json: `git commit -am "update to the next alpha version"`
85
111
  - Update blueprint dependencies to alpha
86
112
 
@@ -89,7 +115,7 @@ node ./dev/update-blueprint-dependencies.js --ember-source=alpha --ember-data=ca
89
115
  ```
90
116
 
91
117
  - commit this update `git commit -am "update blueprint dependencies to alpha"`
92
- - push and open a PR targeting `master`
118
+ - push and open a PR targeting `master` with a PR title like `Prepare 6.6-alpha`
93
119
  - mark this PR as an `enchancement` if the next alpha is a minor release
94
120
  - check that everything is ok i.e. CI passes
95
121
  - merge the `merge-beta` branch into `master` in GitHub
@@ -3,7 +3,7 @@
3
3
  "logo": "https://ember-cli.com/assets/images/ember-cli-logo-small-dark.png",
4
4
  "name": "ember-cli",
5
5
  "description": "Command line tool for developing ambitious ember.js apps",
6
- "version": "6.7.0-beta.1-beta-5e6c3164af"
6
+ "version": "6.8.0-alpha.2-master-9842a0708f"
7
7
  },
8
8
  "files": {
9
9
  "lib/broccoli/default-packager.js": {
@@ -10,6 +10,7 @@ const normalizeBlueprint = require('../utilities/normalize-blueprint-option');
10
10
  const mergeBlueprintOptions = require('../utilities/merge-blueprint-options');
11
11
  const { isPnpmProject, isYarnProject } = require('../utilities/package-managers');
12
12
  const getLangArg = require('../../lib/utilities/get-lang-arg');
13
+ const { deprecate, DEPRECATIONS } = require('../debug');
13
14
 
14
15
  module.exports = Command.extend({
15
16
  name: 'init',
@@ -39,7 +40,12 @@ module.exports = Command.extend({
39
40
  type: String,
40
41
  description: 'Sets the base human language of the application via index.html',
41
42
  },
42
- { name: 'embroider', type: Boolean, default: false, description: 'Enables the build system to use Embroider' },
43
+ {
44
+ name: 'embroider',
45
+ type: Boolean,
46
+ default: false,
47
+ description: 'Deprecated: Enables the build system to use Embroider',
48
+ },
43
49
  {
44
50
  name: 'ci-provider',
45
51
  type: ['github', 'none'],
@@ -74,6 +80,12 @@ module.exports = Command.extend({
74
80
  beforeRun: mergeBlueprintOptions,
75
81
 
76
82
  async run(commandOptions, rawArgs) {
83
+ deprecate(
84
+ "Don't use `--embroider` option. Use `-b @ember/app-blueprint` instead.",
85
+ !commandOptions.embroider,
86
+ DEPRECATIONS.EMBROIDER.options
87
+ );
88
+
77
89
  if (commandOptions.dryRun) {
78
90
  commandOptions.skipNpm = true;
79
91
  }
@@ -107,12 +119,20 @@ module.exports = Command.extend({
107
119
 
108
120
  merge(blueprintOpts, {
109
121
  rawName: packageName,
110
- targetFiles: rawArgs || '',
122
+ targetFiles: rawArgs || [],
111
123
  rawArgs: rawArgs.toString(),
112
124
  blueprint: normalizeBlueprint(blueprintOpts.blueprint || this._defaultBlueprint()),
113
125
  ciProvider,
114
126
  });
115
127
 
128
+ let { targetFiles } = blueprintOpts;
129
+
130
+ deprecate(
131
+ `Do not pass file names or globs to \`init\`. Passed: "${targetFiles.join(' ')}"`,
132
+ targetFiles.length === 0,
133
+ DEPRECATIONS.INIT_TARGET_FILES.options
134
+ );
135
+
116
136
  if (!isValidProjectName(packageName)) {
117
137
  return Promise.reject(new SilentError(`We currently do not support a name of \`${packageName}\`.`));
118
138
  }
@@ -142,5 +162,11 @@ module.exports = Command.extend({
142
162
  this.ui.writeLine(` ${chalk.gray('$')} ${chalk.cyan(`${commandOptions.packageManager ?? 'npm'} start`)}`);
143
163
  this.ui.writeLine('');
144
164
  this.ui.writeLine('Happy coding!');
165
+
166
+ deprecate(
167
+ "Don't use `--embroider` option. Use `-b @ember/app-blueprint` instead.",
168
+ !commandOptions.embroider,
169
+ DEPRECATIONS.EMBROIDER.options
170
+ );
145
171
  },
146
172
  });
@@ -7,6 +7,7 @@ const SilentError = require('silent-error');
7
7
  const isValidProjectName = require('../utilities/valid-project-name');
8
8
  const normalizeBlueprint = require('../utilities/normalize-blueprint-option');
9
9
  const mergeBlueprintOptions = require('../utilities/merge-blueprint-options');
10
+ const { deprecate, DEPRECATIONS } = require('../debug');
10
11
 
11
12
  module.exports = Command.extend({
12
13
  name: 'new',
@@ -37,7 +38,12 @@ module.exports = Command.extend({
37
38
  description: 'Sets the base human language of the application via index.html',
38
39
  },
39
40
  { name: 'lint-fix', type: Boolean, default: true },
40
- { name: 'embroider', type: Boolean, default: false, description: 'Enables the build system to use Embroider' },
41
+ {
42
+ name: 'embroider',
43
+ type: Boolean,
44
+ default: false,
45
+ description: 'Deprecated: Enables the build system to use Embroider',
46
+ },
41
47
  {
42
48
  name: 'ci-provider',
43
49
  type: ['github', 'none'],
@@ -70,6 +76,12 @@ module.exports = Command.extend({
70
76
  beforeRun: mergeBlueprintOptions,
71
77
 
72
78
  async run(commandOptions, rawArgs) {
79
+ deprecate(
80
+ "Don't use `--embroider` option. Use `-b @ember/app-blueprint` instead.",
81
+ !commandOptions.embroider,
82
+ DEPRECATIONS.EMBROIDER.options
83
+ );
84
+
73
85
  let projectName = rawArgs[0],
74
86
  message;
75
87
 
@@ -141,6 +153,12 @@ module.exports = Command.extend({
141
153
 
142
154
  initCommand.project.root = process.cwd();
143
155
 
156
+ deprecate(
157
+ "Don't use `--embroider` option. Use `-b @ember/app-blueprint` instead.",
158
+ !commandOptions.embroider,
159
+ DEPRECATIONS.EMBROIDER.options
160
+ );
161
+
144
162
  return await initCommand.run(commandOptions, rawArgs);
145
163
  },
146
164
  });
@@ -23,6 +23,25 @@ const DEPRECATIONS = {
23
23
  types: ['app-prefix', 'app-suffix', 'tests-prefix', 'tests-suffix', 'vendor-prefix', 'vendor-suffix'],
24
24
  },
25
25
  }),
26
+ EMBROIDER: deprecation({
27
+ for: 'ember-cli',
28
+ id: 'ember-cli.dont-use-embroider-option',
29
+ since: {
30
+ available: '6.8.0',
31
+ },
32
+ until: '7.0.0',
33
+ url: 'https://deprecations.emberjs.com/id/dont-use-embroider-option',
34
+ }),
35
+
36
+ INIT_TARGET_FILES: deprecation({
37
+ for: 'ember-cli',
38
+ id: 'ember-cli.init-target-files',
39
+ since: {
40
+ available: '6.8.0',
41
+ },
42
+ until: '7.0.0',
43
+ url: 'https://deprecations.emberjs.com/id/init-no-file-names',
44
+ }),
26
45
  };
27
46
 
28
47
  module.exports = DEPRECATIONS;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-cli",
3
- "version": "6.7.0-beta.1",
3
+ "version": "6.8.0-alpha.2",
4
4
  "description": "Command line tool for developing ambitious ember.js apps",
5
5
  "keywords": [
6
6
  "app",
@@ -31,12 +31,10 @@
31
31
  "minor": "prerelease",
32
32
  "patch": "prerelease"
33
33
  },
34
- "semverIncrementTag": "beta",
35
- "publishTag": "beta"
34
+ "semverIncrementTag": "alpha",
35
+ "publishTag": "alpha"
36
36
  },
37
37
  "dependencies": {
38
- "@ember-tooling/blueprint-blueprint": "^0.0.2",
39
- "@ember-tooling/blueprint-model": "^0.0.2",
40
38
  "@pnpm/find-workspace-dir": "^1000.1.0",
41
39
  "babel-remove-types": "^1.0.1",
42
40
  "broccoli": "^3.5.2",
@@ -81,7 +79,7 @@
81
79
  "git-repo-info": "^2.1.1",
82
80
  "glob": "^8.1.0",
83
81
  "heimdalljs": "^0.2.6",
84
- "heimdalljs-fs-monitor": "^1.1.1",
82
+ "heimdalljs-fs-monitor": "^1.1.2",
85
83
  "heimdalljs-graph": "^1.0.0",
86
84
  "heimdalljs-logger": "^0.1.10",
87
85
  "http-proxy": "^1.18.1",
@@ -119,11 +117,12 @@
119
117
  "watch-detector": "^1.0.2",
120
118
  "workerpool": "^9.2.0",
121
119
  "yam": "^1.0.0",
122
- "@ember-tooling/classic-build-addon-blueprint": "6.7.0-beta.1",
123
- "@ember-tooling/classic-build-app-blueprint": "6.7.0-beta.1"
120
+ "@ember-tooling/blueprint-blueprint": "0.0.2",
121
+ "@ember-tooling/blueprint-model": "0.0.2",
122
+ "@ember-tooling/classic-build-addon-blueprint": "6.8.0-alpha.2",
123
+ "@ember-tooling/classic-build-app-blueprint": "6.8.0-alpha.2"
124
124
  },
125
125
  "devDependencies": {
126
- "@octokit/rest": "^19.0.7",
127
126
  "broccoli-plugin": "^4.0.3",
128
127
  "broccoli-test-helper": "^2.0.0",
129
128
  "chai": "^4.3.7",
@@ -243,7 +243,7 @@ module.exports = {
243
243
  npm: options.packageManager !== 'yarn' && options.packageManager !== 'pnpm',
244
244
  invokeScriptPrefix,
245
245
  welcome: options.welcome,
246
- blueprint: 'addon',
246
+ blueprint: '@ember-tooling/classic-build-addon-blueprint',
247
247
  blueprintOptions,
248
248
  embroider: false,
249
249
  lang: options.lang,
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@ember-tooling/classic-build-addon-blueprint",
3
- "version": "6.7.0-beta.1",
3
+ "version": "6.8.0-alpha.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/ember-cli/ember-cli.git",
7
7
  "directory": "packages/addon-blueprint"
8
8
  },
9
9
  "dependencies": {
10
- "@ember-tooling/blueprint-model": "^0.0.2",
10
+ "@ember-tooling/blueprint-model": "workspace:*",
11
11
  "chalk": "^4.1.2",
12
12
  "ember-cli-normalize-entity-name": "^1.0.0",
13
13
  "ember-cli-string-utils": "^1.1.0",
@@ -22,7 +22,7 @@
22
22
  "minor": "prerelease",
23
23
  "patch": "prerelease"
24
24
  },
25
- "semverIncrementTag": "beta",
26
- "publishTag": "beta"
25
+ "semverIncrementTag": "alpha",
26
+ "publishTag": "alpha"
27
27
  }
28
28
  }
@@ -69,6 +69,7 @@ export default [
69
69
  },
70
70
  },
71
71
  {
72
+ ...qunit.configs.recommended,
72
73
  files: ['tests/**/*-test.{js,gjs}'],
73
74
  plugins: {
74
75
  qunit,
@@ -78,6 +79,7 @@ export default [
78
79
  * CJS node files
79
80
  */
80
81
  {
82
+ ...n.configs['flat/recommended-script'],
81
83
  files: [
82
84
  '**/*.cjs',
83
85
  'config/**/*.js',
@@ -106,6 +108,7 @@ export default [
106
108
  * ESM node files
107
109
  */
108
110
  {
111
+ ...n.configs['flat/recommended-module'],
109
112
  files: ['**/*.mjs'],
110
113
  plugins: {
111
114
  n,
@@ -12,6 +12,8 @@
12
12
  * npx eslint --inspect-config
13
13
  *
14
14
  */
15
+ import { fileURLToPath } from 'node:url';
16
+ import { dirname } from 'node:path';
15
17
  import globals from 'globals';
16
18
  import js from '@eslint/js';
17
19
 
@@ -42,7 +44,7 @@ const parserOptions = {
42
44
  },
43
45
  ts: {
44
46
  projectService: true,
45
- tsconfigRootDir: import.meta.dirname,
47
+ tsconfigRootDir: dirname(fileURLToPath(import.meta.url)),
46
48
  },
47
49
  },
48
50
  };
@@ -92,6 +94,7 @@ export default ts.config(
92
94
  extends: [...ts.configs.recommendedTypeChecked, ember.configs.gts],
93
95
  },
94
96
  {
97
+ ...qunit.configs.recommended,
95
98
  files: ['tests/**/*-test.{js,gjs,ts,gts}'],
96
99
  plugins: {
97
100
  qunit,
@@ -101,6 +104,7 @@ export default ts.config(
101
104
  * CJS node files
102
105
  */
103
106
  {
107
+ ...n.configs['flat/recommended-script'],
104
108
  files: [
105
109
  '**/*.cjs',
106
110
  'config/**/*.js',
@@ -129,6 +133,7 @@ export default ts.config(
129
133
  * ESM node files
130
134
  */
131
135
  {
136
+ ...n.configs['flat/recommended-module'],
132
137
  files: ['**/*.mjs'],
133
138
  plugins: {
134
139
  n,
@@ -2,13 +2,11 @@
2
2
  "schemaVersion": "1.0.0",
3
3
  "packages": [
4
4
  {
5
- "name": "ember-cli",
5
+ "name": "<%= blueprint %>",
6
6
  "version": "<%= blueprintVersion %>",
7
7
  "blueprints": [
8
8
  {
9
9
  "name": "<%= blueprint %>",
10
- "outputRepo": "https://github.com/ember-cli/ember-<%= blueprint === 'app' ? 'new' : 'addon' %>-output",
11
- "codemodsSource": "ember-<%= blueprint %>-codemods-manifest@1",
12
10
  "isBaseBlueprint": true,
13
11
  "options": [<%= blueprintOptions %>]
14
12
  }
@@ -31,16 +31,16 @@
31
31
  "@babel/core": "^7.28.0",
32
32
  "@babel/eslint-parser": "^7.28.0",
33
33
  "@babel/plugin-proposal-decorators": "^7.28.0<% if (typescript && emberData) { %>",
34
- "@ember-data/adapter": "~5.6.0-beta.2",
35
- "@ember-data/graph": "~5.6.0-beta.2",
36
- "@ember-data/json-api": "~5.6.0-beta.2",
37
- "@ember-data/legacy-compat": "~5.6.0-beta.2",
38
- "@ember-data/model": "~5.6.0-beta.2",
39
- "@ember-data/request": "~5.6.0-beta.2",
40
- "@ember-data/request-utils": "~5.6.0-beta.2",
41
- "@ember-data/serializer": "~5.6.0-beta.2",
42
- "@ember-data/store": "~5.6.0-beta.2",
43
- "@warp-drive/ember": "~5.6.0-beta.2<% } %>",
34
+ "@ember-data/adapter": "~5.7.0-alpha.22",
35
+ "@ember-data/graph": "~5.7.0-alpha.22",
36
+ "@ember-data/json-api": "~5.7.0-alpha.22",
37
+ "@ember-data/legacy-compat": "~5.7.0-alpha.22",
38
+ "@ember-data/model": "~5.7.0-alpha.22",
39
+ "@ember-data/request": "~5.7.0-alpha.22",
40
+ "@ember-data/request-utils": "~5.7.0-alpha.22",
41
+ "@ember-data/serializer": "~5.7.0-alpha.22",
42
+ "@ember-data/store": "~5.7.0-alpha.22",
43
+ "@warp-drive/ember": "~5.7.0-alpha.22<% } %>",
44
44
  "@ember/optional-features": "^2.2.0",
45
45
  "@ember/test-helpers": "^5.2.2<% if (embroider) { %>",
46
46
  "@embroider/compat": "^3.9.1",
@@ -56,11 +56,11 @@
56
56
  "@tsconfig/ember": "^3.0.11",
57
57
  "@types/qunit": "^2.19.12",
58
58
  "@types/rsvp": "^4.0.9<% if (emberData) {%>",
59
- "@warp-drive/core-types": "~5.6.0-beta.2<% }} %>",
59
+ "@warp-drive/core-types": "~5.7.0-alpha.22<% }} %>",
60
60
  "broccoli-asset-rev": "^3.0.0",
61
61
  "concurrently": "^9.2.0",
62
62
  "ember-auto-import": "^2.10.0",
63
- "ember-cli": "~6.7.0-beta.1",
63
+ "ember-cli": "~6.8.0-alpha.2",
64
64
  "ember-cli-app-version": "^7.0.0",
65
65
  "ember-cli-babel": "^8.2.0",
66
66
  "ember-cli-clean-css": "^3.0.0",
@@ -70,13 +70,13 @@
70
70
  "ember-cli-inject-live-reload": "^2.1.0<% if (!embroider) { %>",
71
71
  "ember-cli-sri": "^2.1.1",
72
72
  "ember-cli-terser": "^4.0.2<% } %><% if (emberData) { %>",
73
- "ember-data": "~5.6.0-beta.2<% } %>",
73
+ "ember-data": "~5.7.0-alpha.22<% } %>",
74
74
  "ember-load-initializers": "^3.0.1",
75
75
  "ember-modifier": "^4.2.2",
76
76
  "ember-page-title": "^9.0.2",
77
77
  "ember-qunit": "^9.0.3",
78
78
  "ember-resolver": "^13.1.1",
79
- "ember-source": "~6.7.0-beta.1",
79
+ "ember-source": "~6.8.0-alpha.2",
80
80
  "ember-template-imports": "^4.3.0",
81
81
  "ember-template-lint": "^6.1.0<% if (welcome) { %>",
82
82
  "ember-welcome-page": "^7.0.2<% } %>",
@@ -94,7 +94,7 @@
94
94
  "stylelint": "^16.23.0",
95
95
  "stylelint-config-standard": "^36.0.1",
96
96
  "tracked-built-ins": "^3.4.0<% if (typescript) { %>",
97
- "typescript": "^5.8.3",
97
+ "typescript": "^5.9.2",
98
98
  "typescript-eslint": "^8.38.0<% } %>",
99
99
  "webpack": "^5.101.0"
100
100
  },
@@ -75,7 +75,7 @@ module.exports = {
75
75
  invokeScriptPrefix,
76
76
  execBinPrefix,
77
77
  welcome: options.welcome,
78
- blueprint: 'app',
78
+ blueprint: '@ember-tooling/classic-build-app-blueprint',
79
79
  blueprintOptions,
80
80
  embroider,
81
81
  lang: options.lang,
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@ember-tooling/classic-build-app-blueprint",
3
- "version": "6.7.0-beta.1",
3
+ "version": "6.8.0-alpha.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/ember-cli/ember-cli.git",
7
7
  "directory": "packages/app-blueprint"
8
8
  },
9
9
  "dependencies": {
10
- "@ember-tooling/blueprint-model": "^0.0.2",
10
+ "@ember-tooling/blueprint-model": "workspace:*",
11
11
  "chalk": "^4.1.2",
12
12
  "ember-cli-string-utils": "^1.1.0"
13
13
  },
@@ -16,7 +16,7 @@
16
16
  "minor": "prerelease",
17
17
  "patch": "prerelease"
18
18
  },
19
- "semverIncrementTag": "beta",
20
- "publishTag": "beta"
19
+ "semverIncrementTag": "alpha",
20
+ "publishTag": "alpha"
21
21
  }
22
22
  }
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ description: ''
5
+
6
+ // locals(options) {
7
+ // // Return custom template variables here.
8
+ // return {
9
+ // foo: options.entity.options.foo
10
+ // };
11
+ // }
12
+
13
+ // afterInstall(options) {
14
+ // // Perform extra work here.
15
+ // }
16
+ };
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ description: 'Generates a blueprint and definition.',
5
+ };
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "@ember-tooling/blueprint-blueprint",
3
+ "version": "0.0.2",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/ember-cli/ember-cli.git",
7
+ "directory": "packages/blueprint-blueprint"
8
+ }
9
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "@ember-tooling/blueprint-model",
3
+ "version": "0.0.2",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/ember-cli/ember-cli.git",
7
+ "directory": "packages/blueprint-model"
8
+ },
9
+ "dependencies": {
10
+ "chalk": "^4.1.2",
11
+ "diff": "^7.0.0",
12
+ "isbinaryfile": "^5.0.4",
13
+ "lodash": "^4.17.21",
14
+ "promise.hash.helper": "^1.0.8",
15
+ "quick-temp": "^0.1.8",
16
+ "silent-error": "^1.1.1"
17
+ }
18
+ }
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+
5
+ /**
6
+ * Derive a directory name from a package name.
7
+ * Takes scoped packages into account.
8
+ *
9
+ * @method directoryForPackageName
10
+ * @param {String} packageName
11
+ * @return {String} Derived directory name.
12
+ */
13
+ module.exports = function directoryForPackageName(packageName) {
14
+ let isScoped = packageName[0] === '@' && packageName.includes('/');
15
+
16
+ if (isScoped) {
17
+ let slashIndex = packageName.indexOf('/');
18
+ let scopeName = packageName.substring(1, slashIndex);
19
+ let packageNameWithoutScope = packageName.substring(slashIndex + 1);
20
+ let pathParts = process.cwd().split(path.sep);
21
+ let parentDirectoryContainsScopeName = pathParts.includes(scopeName);
22
+
23
+ if (parentDirectoryContainsScopeName) {
24
+ return packageNameWithoutScope;
25
+ } else {
26
+ return `${scopeName}-${packageNameWithoutScope}`;
27
+ }
28
+ } else {
29
+ return packageName;
30
+ }
31
+ };
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const util = require('util');
5
+ const jsdiff = require('diff');
6
+ const quickTemp = require('quick-temp');
7
+ const path = require('path');
8
+ const SilentError = require('silent-error');
9
+ const openEditor = require('./open-editor');
10
+ const hash = require('promise.hash.helper');
11
+
12
+ const readFile = util.promisify(fs.readFile);
13
+ const writeFile = util.promisify(fs.writeFile);
14
+
15
+ class EditFileDiff {
16
+ constructor(options) {
17
+ this.info = options.info;
18
+
19
+ quickTemp.makeOrRemake(this, 'tmpDifferenceDir');
20
+ }
21
+
22
+ edit() {
23
+ return hash({
24
+ input: this.info.render(),
25
+ output: readFile(this.info.outputPath),
26
+ })
27
+ .then(this.invokeEditor.bind(this))
28
+ .then(this.applyPatch.bind(this))
29
+ .finally(this.cleanUp.bind(this));
30
+ }
31
+
32
+ cleanUp() {
33
+ quickTemp.remove(this, 'tmpDifferenceDir');
34
+ }
35
+
36
+ applyPatch(resultHash) {
37
+ return hash({
38
+ diffString: readFile(resultHash.diffPath),
39
+ currentString: readFile(resultHash.outputPath),
40
+ }).then((result) => {
41
+ let appliedDiff = jsdiff.applyPatch(result.currentString.toString(), result.diffString.toString());
42
+
43
+ if (!appliedDiff) {
44
+ let message = 'Patch was not cleanly applied.';
45
+ this.info.ui.writeLine(`${message} Please choose another action.`);
46
+ throw new SilentError(message);
47
+ }
48
+
49
+ return writeFile(resultHash.outputPath, appliedDiff);
50
+ });
51
+ }
52
+
53
+ invokeEditor(result) {
54
+ let info = this.info;
55
+ let diff = jsdiff.createPatch(info.outputPath, result.output.toString(), result.input);
56
+ let diffPath = path.join(this.tmpDifferenceDir, 'currentDiff.diff');
57
+
58
+ return writeFile(diffPath, diff)
59
+ .then(() => openEditor(diffPath))
60
+ .then(() => ({ outputPath: info.outputPath, diffPath }));
61
+ }
62
+ }
63
+
64
+ module.exports = EditFileDiff;
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ const chalk = require('chalk');
4
+ const availableExperiments = Object.freeze(['EMBROIDER', 'CLASSIC']);
5
+
6
+ const deprecatedExperiments = Object.freeze([]);
7
+ const enabledExperiments = Object.freeze([]);
8
+ const deprecatedExperimentsDeprecationsIssued = [];
9
+
10
+ function isExperimentEnabled(experimentName) {
11
+ if (!availableExperiments.includes(experimentName)) {
12
+ return false;
13
+ }
14
+
15
+ if (process.env.EMBER_CLI_ENABLE_ALL_EXPERIMENTS && deprecatedExperiments.includes(experimentName)) {
16
+ return false;
17
+ }
18
+
19
+ if (process.env.EMBER_CLI_ENABLE_ALL_EXPERIMENTS) {
20
+ return true;
21
+ }
22
+
23
+ if (process.env.EMBER_CLI_CLASSIC && experimentName === 'EMBROIDER') {
24
+ return false;
25
+ }
26
+
27
+ let experimentEnvironmentVariable = `EMBER_CLI_${experimentName}`;
28
+ let experimentValue = process.env[experimentEnvironmentVariable];
29
+
30
+ if (deprecatedExperiments.includes(experimentName)) {
31
+ let deprecationPreviouslyIssued = deprecatedExperimentsDeprecationsIssued.includes(experimentName);
32
+ let isSpecifiedByUser = experimentValue !== undefined;
33
+
34
+ if (!deprecationPreviouslyIssued && isSpecifiedByUser) {
35
+ console.warn(
36
+ chalk.yellow(`The ${experimentName} experiment in ember-cli has been deprecated and will be removed.`)
37
+ );
38
+ deprecatedExperimentsDeprecationsIssued.push(experimentName);
39
+ }
40
+ }
41
+
42
+ if (enabledExperiments.includes(experimentName)) {
43
+ return experimentValue !== 'false';
44
+ } else {
45
+ return experimentValue !== undefined && experimentValue !== 'false';
46
+ }
47
+ }
48
+
49
+ module.exports = {
50
+ isExperimentEnabled,
51
+
52
+ // exported for testing purposes
53
+ _deprecatedExperimentsDeprecationsIssued: deprecatedExperimentsDeprecationsIssued,
54
+ };
@@ -0,0 +1,170 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const util = require('util');
5
+ const chalk = require('chalk');
6
+ const EditFileDiff = require('./edit-file-diff');
7
+ const EOL = require('os').EOL;
8
+ const rxEOL = new RegExp(EOL, 'g');
9
+ const isBinaryFile = require('isbinaryfile').isBinaryFileSync;
10
+ const hash = require('promise.hash.helper');
11
+ const canEdit = require('./open-editor').canEdit;
12
+ const processTemplate = require('./process-template');
13
+
14
+ const readFile = util.promisify(fs.readFile);
15
+ const lstat = util.promisify(fs.stat);
16
+
17
+ function diffHighlight(line) {
18
+ if (line[0] === '+') {
19
+ return chalk.green(line);
20
+ } else if (line[0] === '-') {
21
+ return chalk.red(line);
22
+ } else if (/^@@/.test(line)) {
23
+ return chalk.cyan(line);
24
+ } else {
25
+ return line;
26
+ }
27
+ }
28
+
29
+ const NOOP = (_) => _;
30
+ class FileInfo {
31
+ constructor(options) {
32
+ this.action = options.action;
33
+ this.outputBasePath = options.outputBasePath;
34
+ this.outputPath = options.outputPath;
35
+ this.displayPath = options.displayPath;
36
+ this.inputPath = options.inputPath;
37
+ this.templateVariables = options.templateVariables;
38
+ this.replacer = options.replacer || NOOP;
39
+ this.ui = options.ui;
40
+ }
41
+
42
+ confirmOverwrite(path) {
43
+ let promptOptions = {
44
+ type: 'expand',
45
+ name: 'answer',
46
+ default: false,
47
+ message: `${chalk.red('Overwrite')} ${path}?`,
48
+ choices: [
49
+ { key: 'y', name: 'Yes, overwrite', value: 'overwrite' },
50
+ { key: 'n', name: 'No, skip', value: 'skip' },
51
+ ],
52
+ };
53
+
54
+ let outputPathIsFile = false;
55
+ try {
56
+ outputPathIsFile = fs.statSync(this.outputPath).isFile();
57
+ } catch (err) {
58
+ /* ignore */
59
+ }
60
+
61
+ let canDiff = !isBinaryFile(this.inputPath) && (!outputPathIsFile || !isBinaryFile(this.outputPath));
62
+
63
+ if (canDiff) {
64
+ promptOptions.choices.push({ key: 'd', name: 'Diff', value: 'diff' });
65
+
66
+ if (canEdit()) {
67
+ promptOptions.choices.push({ key: 'e', name: 'Edit', value: 'edit' });
68
+ }
69
+ }
70
+
71
+ return this.ui.prompt(promptOptions).then((response) => response.answer);
72
+ }
73
+
74
+ displayDiff() {
75
+ let info = this,
76
+ jsdiff = require('diff');
77
+ return hash({
78
+ input: this.render(),
79
+ output: readFile(info.outputPath),
80
+ }).then((result) => {
81
+ let diff = jsdiff.createPatch(
82
+ info.outputPath,
83
+ result.output.toString().replace(rxEOL, '\n'),
84
+ result.input.replace(rxEOL, '\n')
85
+ );
86
+ let lines = diff.split('\n');
87
+
88
+ for (let i = 0; i < lines.length; i++) {
89
+ info.ui.write(diffHighlight(lines[i] + EOL));
90
+ }
91
+ });
92
+ }
93
+
94
+ async render() {
95
+ if (!this.rendered) {
96
+ let result = await this._render();
97
+ this.rendered = this.replacer(result, this);
98
+ }
99
+
100
+ return this.rendered;
101
+ }
102
+
103
+ _render() {
104
+ let path = this.inputPath;
105
+ let context = this.templateVariables;
106
+
107
+ return readFile(path).then((content) =>
108
+ lstat(path).then((fileStat) => {
109
+ if (isBinaryFile(content, fileStat.size)) {
110
+ return content;
111
+ } else {
112
+ try {
113
+ return processTemplate(content.toString(), context);
114
+ } catch (err) {
115
+ err.message += ` (Error in blueprint template: ${path})`;
116
+ throw err;
117
+ }
118
+ }
119
+ })
120
+ );
121
+ }
122
+
123
+ checkForConflict() {
124
+ return this.render().then((input) => {
125
+ input = input.toString().replace(rxEOL, '\n');
126
+
127
+ return readFile(this.outputPath)
128
+ .then((output) => {
129
+ output = output.toString().replace(rxEOL, '\n');
130
+
131
+ return input === output ? 'identical' : 'confirm';
132
+ })
133
+ .catch((e) => {
134
+ if (e.code === 'ENOENT') {
135
+ return 'none';
136
+ }
137
+
138
+ throw e;
139
+ });
140
+ });
141
+ }
142
+
143
+ confirmOverwriteTask() {
144
+ let info = this;
145
+
146
+ return function () {
147
+ function doConfirm() {
148
+ return info.confirmOverwrite(info.displayPath).then((action) => {
149
+ if (action === 'diff') {
150
+ return info.displayDiff().then(doConfirm);
151
+ } else if (action === 'edit') {
152
+ let editFileDiff = new EditFileDiff({ info });
153
+ return editFileDiff
154
+ .edit()
155
+ .then(() => (info.action = action))
156
+ .catch(() => doConfirm())
157
+ .then(() => info);
158
+ } else {
159
+ info.action = action;
160
+ return info;
161
+ }
162
+ });
163
+ }
164
+
165
+ return doConfirm();
166
+ };
167
+ }
168
+ }
169
+
170
+ module.exports = FileInfo;
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ const spawn = require('child_process').spawn;
4
+
5
+ function openEditor(file) {
6
+ if (!openEditor.canEdit()) {
7
+ throw new Error('EDITOR environment variable is not set');
8
+ }
9
+
10
+ if (!file) {
11
+ throw new Error('No `file` option provided');
12
+ }
13
+
14
+ let editorArgs = openEditor._env().EDITOR.split(' ');
15
+ let editor = editorArgs.shift();
16
+ const args = [file].concat(editorArgs);
17
+ let editProcess = openEditor._spawn(editor, args, { stdio: 'inherit' });
18
+
19
+ return new Promise((resolve, reject) => {
20
+ editProcess.on('close', (code) => {
21
+ if (code === 0) {
22
+ resolve();
23
+ } else {
24
+ reject(
25
+ new Error(`Spawn('${editor}', [${args.join(',')}]) exited with a non zero error status code: '${code}'`)
26
+ );
27
+ }
28
+ });
29
+ });
30
+ }
31
+
32
+ openEditor.canEdit = function () {
33
+ return openEditor._env().EDITOR !== undefined;
34
+ };
35
+
36
+ openEditor._env = function () {
37
+ return process.env;
38
+ };
39
+
40
+ openEditor._spawn = function () {
41
+ return spawn.apply(this, arguments);
42
+ };
43
+
44
+ module.exports = openEditor;
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ function supportEmoji() {
4
+ const hasEmojiTurnedOff = process.argv.indexOf('--no-emoji') > -1;
5
+ return process.stdout.isTTY && process.platform !== 'win32' && !hasEmojiTurnedOff;
6
+ }
7
+
8
+ const areEmojiSupported = supportEmoji();
9
+
10
+ module.exports = function prependEmoji(emoji, msg) {
11
+ return areEmojiSupported ? `${emoji} ${msg}` : msg;
12
+ };
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ module.exports = function processTemplate(content, context) {
4
+ let options = {
5
+ evaluate: /<%([\s\S]+?)%>/g,
6
+ interpolate: /<%=([\s\S]+?)%>/g,
7
+ escape: /<%-([\s\S]+?)%>/g,
8
+ };
9
+ return require('lodash/template')(content, options)(context);
10
+ };