Skip to content
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

Added blueprints to package.json's files #74

Merged
merged 4 commits into from
Dec 26, 2023
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
11 changes: 11 additions & 0 deletions src/steps/analyze-addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,20 @@ function getPublicAssets(options: Options): Record<string, string> {
);
}

function hasBlueprints(options: Options): boolean {
const { projectRoot } = options;

const filePaths = findFiles('blueprints/**/*', {
projectRoot,
});

return filePaths.length > 0;
}

export function analyzeAddon(options: Options): Context {
return {
addon: {
hasBlueprints: hasBlueprints(options),
publicAssets: getPublicAssets(options),
},
projectRoot: {
Expand Down
20 changes: 12 additions & 8 deletions src/steps/update-addon-package-json/update-other-fields.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Context, Options, PackageJson } from '../../types/index.js';

type Data = {
hasBlueprints: boolean;
hasPublicAssets: boolean;
hasTypeScript: boolean;
publicAssets: Record<string, string>;
Expand Down Expand Up @@ -59,10 +60,14 @@ function updateExports(packageJson: PackageJson, data: Data): void {
}

function updateFiles(packageJson: PackageJson, data: Data): void {
const { hasPublicAssets, hasTypeScript } = data;
const { hasBlueprints, hasPublicAssets, hasTypeScript } = data;

const files = new Set(['addon-main.cjs', 'dist']);

if (hasBlueprints) {
files.add('blueprints');
}

if (hasPublicAssets) {
files.add('public');
}
Expand Down Expand Up @@ -93,15 +98,14 @@ export function updateOtherFields(
context: Context,
options: Options,
): void {
const { addon } = context;
const { packages } = options;

const hasPublicAssets = Object.keys(addon.publicAssets).length > 0;
const { hasBlueprints, publicAssets } = context.addon;
const { hasTypeScript } = options.packages.addon;

const data = {
hasPublicAssets,
hasTypeScript: packages.addon.hasTypeScript,
publicAssets: addon.publicAssets,
hasBlueprints,
hasPublicAssets: Object.keys(publicAssets).length > 0,
hasTypeScript,
publicAssets,
};

updateEmberAddon(packageJson, data);
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type CodemodOptions = {

type Context = {
addon: {
hasBlueprints: boolean;
publicAssets: Record<string, string>;
};
projectRoot: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
description: 'Generates something',
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
{
"name": "ember-container-query",
"version": "3.2.0",
"description": "Container queries using Ember modifiers",
"keywords": [
"container-queries",
"container-query",
"element-queries",
"element-query",
"ember-addon",
"ember-octane",
"emberjs",
"glint",
"responsive-design"
],
"repository": {
"type": "git",
"url": "https://github.com/ijlee2/ember-container-query.git"
},
"license": "MIT",
"author": "Isaac J. Lee",
"directories": {
"doc": "doc",
"test": "tests"
},
"scripts": {
"build": "ember build --environment=production",
"build:test": "ember build --environment=test",
"changelog": "lerna-changelog",
"lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"",
"lint:css": "stylelint \"tests/dummy/app/**/*.css\" --cache",
"lint:css:fix": "stylelint \"tests/dummy/app/**/*.css\" --fix",
"lint:dependency": "ember dependency-lint",
"lint:fix": "concurrently \"npm:lint:*:fix\" --names \"fix:\"",
"lint:hbs": "ember-template-lint .",
"lint:hbs:fix": "ember-template-lint . --fix",
"lint:js": "eslint . --cache --ext=.js,.ts",
"lint:js:fix": "eslint . --fix",
"lint:types": "tsc --noEmit",
"prepack": "ember ts:precompile",
"postpack": "ember ts:clean",
"start": "ember serve",
"test": "DEVICE='w3-h3' ember test",
"test:ember": "ember test",
"test:ember-compatibility": "./node_modules/.bin/ember try:one"
},
"changelog": {
"labels": {
"breaking": "Breaking Change",
"bug": "Bug Fix",
"enhance: code": "Enhancement",
"enhance: dependency": "Internal",
"enhance: documentation": "Documentation",
"user feedback": "User Feedback"
}
},
"dependencies": {
"ember-cli-babel": "^7.26.11",
"ember-cli-htmlbars": "^6.1.1",
"ember-cli-typescript": "^5.2.1",
"ember-element-helper": "^0.6.1",
"ember-modifier": "^3.2.7",
"ember-resize-observer-service": "^1.1.0",
"ember-test-selectors": "^6.0.0"
},
"devDependencies": {
"@ember/optional-features": "^2.0.0",
"@ember/test-helpers": "^2.9.3",
"@embroider/test-setup": "^2.0.2",
"@glimmer/component": "^1.1.2",
"@glimmer/tracking": "^1.1.2",
"@percy/cli": "^1.16.0",
"@percy/ember": "^4.0.0",
"@tsconfig/ember": "^2.0.0",
"@types/ember__application": "^4.0.5",
"@types/ember__array": "^4.0.3",
"@types/ember__component": "^4.0.12",
"@types/ember__controller": "^4.0.4",
"@types/ember__debug": "^4.0.3",
"@types/ember__destroyable": "^4.0.1",
"@types/ember__engine": "^4.0.4",
"@types/ember__error": "^4.0.2",
"@types/ember__object": "^4.0.5",
"@types/ember__polyfills": "^4.0.1",
"@types/ember__routing": "^4.0.12",
"@types/ember__runloop": "^4.0.2",
"@types/ember__service": "^4.0.2",
"@types/ember__string": "^3.0.10",
"@types/ember__template": "^4.0.1",
"@types/ember__test": "^4.0.1",
"@types/ember__utils": "^4.0.2",
"@types/htmlbars-inline-precompile": "^3.0.0",
"@types/qunit": "^2.19.3",
"@types/rsvp": "^4.0.4",
"@typescript-eslint/eslint-plugin": "^5.48.0",
"@typescript-eslint/parser": "^5.48.0",
"broccoli-asset-rev": "^3.0.0",
"concurrently": "^7.6.0",
"d3-array": "^3.2.1",
"d3-axis": "^3.0.0",
"d3-scale": "^4.0.2",
"d3-selection": "^3.0.0",
"d3-shape": "^3.2.0",
"ember-a11y-refocus": "^3.0.2",
"ember-a11y-testing": "^5.1.0",
"ember-auto-import": "^2.5.0",
"ember-cli": "~4.9.2",
"ember-cli-dependency-checker": "^3.3.1",
"ember-cli-dependency-lint": "^2.0.1",
"ember-cli-inject-live-reload": "^2.1.0",
"ember-cli-netlify": "^0.4.1",
"ember-cli-sri": "^2.1.1",
"ember-cli-terser": "^4.0.2",
"ember-css-modules": "^2.0.1",
"ember-load-initializers": "^2.1.2",
"ember-page-title": "^7.0.0",
"ember-qunit": "^6.1.1",
"ember-resolver": "^9.0.1",
"ember-source": "~4.9.3",
"ember-source-channel-url": "^3.0.0",
"ember-svg-jar": "^2.4.2",
"ember-template-lint": "^5.3.0",
"ember-template-lint-plugin-prettier": "^4.1.0",
"ember-truth-helpers": "^3.1.1",
"ember-try": "^2.0.0",
"eslint": "^8.31.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-ember": "^11.4.2",
"eslint-plugin-n": "^15.6.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-qunit": "^7.3.4",
"eslint-plugin-simple-import-sort": "^8.0.0",
"eslint-plugin-typescript-sort-keys": "^2.1.0",
"lerna-changelog": "^2.2.0",
"loader.js": "^4.7.0",
"prettier": "^2.8.1",
"qunit": "^2.19.3",
"qunit-dom": "^2.0.0",
"stylelint": "^14.16.1",
"stylelint-config-standard": "^29.0.0",
"stylelint-no-unsupported-browser-features": "^6.0.1",
"stylelint-order": "^6.0.0",
"typescript": "^4.9.4",
"webpack": "^5.75.0"
},
"engines": {
"node": "14.* || 16.* || >= 18"
},
"ember": {
"edition": "octane"
},
"ember-addon": {
"configPath": "tests/dummy/config",
"demoURL": "https://ember-container-query.netlify.app"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
description: 'Generates something',
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"name": "ember-container-query",
"version": "3.2.0",
"description": "Container queries using Ember modifiers",
"keywords": [
"container-queries",
"container-query",
"element-queries",
"element-query",
"ember-addon",
"ember-octane",
"emberjs",
"glint",
"responsive-design"
],
"repository": {
"type": "git",
"url": "https://github.com/ijlee2/ember-container-query.git"
},
"license": "MIT",
"author": "Isaac J. Lee",
"directories": {
"doc": "doc",
"test": "tests"
},
"scripts": {
"build": "concurrently \"npm:build:*\" --names \"build:\"",
"build:js": "rollup --config",
"build:test": "ember build --environment=test",
"build:types": "tsc",
"changelog": "lerna-changelog",
"lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"",
"lint:css": "stylelint \"tests/dummy/app/**/*.css\" --cache",
"lint:css:fix": "stylelint \"tests/dummy/app/**/*.css\" --fix",
"lint:dependency": "ember dependency-lint",
"lint:fix": "concurrently \"npm:lint:*:fix\" --names \"fix:\"",
"lint:hbs": "ember-template-lint .",
"lint:hbs:fix": "ember-template-lint . --fix",
"lint:js": "eslint . --cache --ext=.js,.ts",
"lint:js:fix": "eslint . --fix",
"lint:types": "tsc --emitDeclarationOnly false --noEmit",
"prepack": "rollup --config",
"start": "concurrently \"npm:start:*\" --names \"start:\"",
"start:js": "rollup --config --watch --no-watch.clearScreen",
"start:types": "tsc --watch",
"test": "echo 'A v2 addon does not have tests, run tests in test-app'",
"test:ember": "ember test",
"test:ember-compatibility": "./node_modules/.bin/ember try:one"
},
"changelog": {
"labels": {
"breaking": "Breaking Change",
"bug": "Bug Fix",
"enhance: code": "Enhancement",
"enhance: dependency": "Internal",
"enhance: documentation": "Documentation",
"user feedback": "User Feedback"
}
},
"dependencies": {
"@embroider/addon-shim": "^1.8.7",
"decorator-transforms": "^1.0.1",
"ember-element-helper": "^0.6.1",
"ember-modifier": "^3.2.7",
"ember-resize-observer-service": "^1.1.0",
"ember-test-selectors": "^6.0.0"
},
"devDependencies": {
"@babel/core": "^7.23.6",
"@babel/plugin-transform-typescript": "^7.23.6",
"@babel/runtime": "^7.23.6",
"@embroider/addon-dev": "^4.1.3",
"@rollup/plugin-babel": "^6.0.4",
"@tsconfig/ember": "^2.0.0",
"babel-plugin-ember-template-compilation": "^2.2.1",
"concurrently": "^7.6.0",
"rollup": "^4.9.1",
"rollup-plugin-copy": "^3.5.0",
"typescript": "^4.9.4"
},
"engines": {
"node": "14.* || 16.* || >= 18"
},
"ember": {
"edition": "octane"
},
"ember-addon": {
"app-js": {},
"main": "addon-main.cjs",
"type": "addon",
"version": 2
},
"exports": {
".": {
"types": "./declarations/index.d.ts",
"default": "./dist/index.js"
},
"./*": {
"types": "./declarations/*.d.ts",
"default": "./dist/*.js"
},
"./addon-main.js": "./addon-main.cjs"
},
"files": [
"addon-main.cjs",
"blueprints",
"declarations",
"dist"
],
Comment on lines +104 to +109
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixture ensures that blueprints is included in files.

"typesVersions": {
"*": {
"*": [
"declarations/*"
]
}
}
}
1 change: 1 addition & 0 deletions tests/helpers/shared-test-setups/customizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const codemodOptions: CodemodOptions = {

const context: Context = {
addon: {
hasBlueprints: false,
publicAssets: {},
},
projectRoot: {
Expand Down
1 change: 1 addition & 0 deletions tests/helpers/shared-test-setups/glint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const codemodOptions: CodemodOptions = {

const context: Context = {
addon: {
hasBlueprints: false,
publicAssets: {},
},
projectRoot: {
Expand Down
1 change: 1 addition & 0 deletions tests/helpers/shared-test-setups/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const codemodOptions: CodemodOptions = {

const context: Context = {
addon: {
hasBlueprints: false,
publicAssets: {},
},
projectRoot: {
Expand Down
1 change: 1 addition & 0 deletions tests/helpers/shared-test-setups/scoped.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const codemodOptions: CodemodOptions = {

const context: Context = {
addon: {
hasBlueprints: false,
publicAssets: {},
},
projectRoot: {
Expand Down
Loading