Skip to content

Commit

Permalink
Merge magicspace changes (update)
Browse files Browse the repository at this point in the history
  • Loading branch information
vilicvane committed Oct 16, 2023
2 parents 3c2ff69 + 1a00e8f commit 5c4ca21
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 203 deletions.
9 changes: 6 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
"extends": ["plugin:@mufan/javascript"],
"overrides": [
{
"files": "**/*.{js,jsx}"
"files": "**/*.{js,cjs}",
"parserOptions": {
"sourceType": "script"
}
},
{
"files": "**/*.cjs",
"files": "**/*.mjs",
"parserOptions": {
"sourceType": "script"
"sourceType": "module"
}
}
]
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Magicspace
boilerplate.schema.json
# TypeScript Build Artifacts
bld/
Expand Down
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"files.eol": "\n",
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"typescript.preferences.importModuleSpecifier": "project-relative",
"typescript.preferences.importModuleSpecifierEnding": "js",
"typescript.tsdk": "node_modules/typescript/lib",
"eslint.workingDirectories": [
".",
Expand Down
2 changes: 1 addition & 1 deletion general/src/composables/LICENSE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {composable, handlebars} from '@magicspace/core';

import type {ResolvedOptions} from '../library/index.js';

import {LICENSE_TEMPLATES_DIR} from './@constants';
import {LICENSE_TEMPLATES_DIR} from './@constants.js';

export default composable<ResolvedOptions>(({license, author}) => {
if (!license) {
Expand Down
2 changes: 1 addition & 1 deletion general/src/composables/README.md.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
ResolvedOptions,
} from '../library/index.js';

import {TEMPLATES_DIR} from './@constants';
import {TEMPLATES_DIR} from './@constants.js';

const TEMPLATE_PATH = Path.join(TEMPLATES_DIR, 'README.md.hbs');

Expand Down
18 changes: 10 additions & 8 deletions general/src/composables/prettierignore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ const BOILERPLATE_SCHEMA_FILE_NAME = 'boilerplate.schema.json';

export default composable<ResolvedOptions>(
async ({packageManager, magicspaceDir}) => {
const packageManagerIgnoreEntries =
PACKAGE_MANAGER_IGNORE_ENTRIES_DICT[packageManager];

if (!packageManagerIgnoreEntries) {
return undefined;
}

const boilerplateSchemaExists = await FS.stat(
Path.join(magicspaceDir, BOILERPLATE_SCHEMA_FILE_NAME),
).then(
stats => stats.isFile(),
() => false,
);

const packageManagerIgnoreEntries =
PACKAGE_MANAGER_IGNORE_ENTRIES_DICT[packageManager];

if (!boilerplateSchemaExists && !packageManagerIgnoreEntries) {
return;
}

return text('.prettierignore', content => {
if (boilerplateSchemaExists) {
content += `\
Expand All @@ -36,10 +36,12 @@ ${BOILERPLATE_SCHEMA_FILE_NAME}
`;
}

content += `\
if (packageManagerIgnoreEntries) {
content += `\
# Package Manager
${packageManagerIgnoreEntries.join('\n')}
`;
}

return content;
});
Expand Down
2 changes: 1 addition & 1 deletion general/src/library/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export {default} from './boilerplate';
export {default} from './boilerplate.js';
export * from './boilerplate.js';
export * from './examples.js';
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"typescript": "^5.2.2"
},
"devDependencies": {
"@mufan/eslint-plugin": "^0.2.1",
"@mufan/eslint-plugin": "^0.2.5",
"@types/lodash": "^4.14.159",
"@types/node": "^14.0.27",
"eslint": "^8.51.0",
Expand Down
2 changes: 1 addition & 1 deletion typescript/src/composables/entrances.ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {composable, handlebars} from '@magicspace/core';

import type {ResolvedOptions} from '../library/index.js';

import {TEMPLATES_DIR} from './@constants';
import {TEMPLATES_DIR} from './@constants.js';

const TEMPLATE_PATH = Path.join(TEMPLATES_DIR, '@entrances.ts.hbs');

Expand Down
2 changes: 1 addition & 1 deletion typescript/src/composables/index.ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import _ from 'lodash';

import type {ResolvedOptions} from '../library/index.js';

import {TEMPLATES_DIR} from './@constants';
import {TEMPLATES_DIR} from './@constants.js';

const TEMPLATE_PATH = Path.join(TEMPLATES_DIR, 'index.ts.hbs');

Expand Down
10 changes: 5 additions & 5 deletions typescript/src/library/@boilerplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import {boilerplate, composables} from '@magicspace/core';

import general from '../../../general/bld/library/index.js';

import type {Options} from './options';
import {resolveOptions} from './options';
import type {Options} from './options.js';
import {resolveOptions} from './options.js';

export default boilerplate<Options>(async options => {
export default boilerplate<Options>(async (options, context) => {
return {
extends: await general(options),
extends: await general(options, context),
composables: await composables(
Path.join(__dirname, '../composables'),
resolveOptions(options),
resolveOptions(options, context),
),
};
});
8 changes: 6 additions & 2 deletions typescript/src/library/options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as Path from 'path';

import type {BoilerplateBuilderContext} from '@magicspace/core';
import {x} from '@magicspace/core';
import _ from 'lodash';
import type {OmitValueOfKey} from 'tslang';
Expand Down Expand Up @@ -176,8 +177,11 @@ export type ResolvedOptions = Options &
bldDirNames: string[];
};

export function resolveOptions(options: Options): ResolvedOptions {
const resolvedOptions = resolveGeneralOptions(options);
export function resolveOptions(
options: Options,
context: BoilerplateBuilderContext,
): ResolvedOptions {
const resolvedOptions = resolveGeneralOptions(options, context);

const projectOptionsArray = resolvedOptions.packages.flatMap(
(packageOptions: ResolvedPackageOptions) =>
Expand Down
Loading

0 comments on commit 5c4ca21

Please sign in to comment.