Skip to content

Commit 9866569

Browse files
committed
諸々調整
1 parent fde18e2 commit 9866569

7 files changed

Lines changed: 367 additions & 6 deletions

File tree

package-lock.json

Lines changed: 171 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
"build": "node scripts/build.js",
1212
"prepackage": "npm run build --workspaces --if-present",
1313
"package": "rm -rf build && npm run build && ",
14+
"version:sync": "node scripts/version.js",
1415
"release:commit": "node scripts/commit.js",
15-
"release:patch": "npm version patch -w develop && npm run release:commit",
16-
"release:minor": "npm version minor -w develop && npm run release:commit",
17-
"release:major": "npm version major -w develop && npm run release:commit",
16+
"release:patch": "npm version patch --no-git-tag-version -w develop && npm run version:sync && npm run release:commit",
17+
"release:minor": "npm version minor --no-git-tag-version -w develop && npm run version:sync && npm run release:commit",
18+
"release:major": "npm version major --no-git-tag-version -w develop && npm run version:sync && npm run release:commit",
1819
"check-update": "npx -p npm-check-updates -c ncu",
1920
"prepare": "husky"
2021
},

scripts/version.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
4+
// ファイルパスの設定
5+
const README_PATH = path.join(process.cwd(), 'themes/develop/README.md');
6+
const PACKAGE_PATH = path.join(process.cwd(), 'themes/develop/package.json');
7+
8+
// バージョン番号を抽出する正規表現
9+
const VERSION_REGEX = /Ver\.(\d+\.\d+\.\d+)/;
10+
11+
// ファイルを読み込む関数
12+
function readFile(filePath) {
13+
try {
14+
return fs.readFileSync(filePath, 'utf8');
15+
} catch (error) {
16+
console.error(`Error reading file ${filePath}:`, error);
17+
process.exit(1);
18+
}
19+
}
20+
21+
// ファイルを書き込む関数
22+
function writeFile(filePath, content) {
23+
try {
24+
fs.writeFileSync(filePath, content, 'utf8');
25+
} catch (error) {
26+
console.error(`Error writing file ${filePath}:`, error);
27+
process.exit(1);
28+
}
29+
}
30+
31+
// バージョン番号を更新する関数
32+
function updateVersion() {
33+
// package.jsonからバージョン番号を取得
34+
const packageContent = readFile(PACKAGE_PATH);
35+
const packageJson = JSON.parse(packageContent);
36+
const version = packageJson.version;
37+
console.log(`Found version ${version} in package.json`);
38+
39+
// README.mdを読み込んで更新
40+
const readmeContent = readFile(README_PATH);
41+
const currentVersionMatch = readmeContent.match(VERSION_REGEX);
42+
43+
if (!currentVersionMatch) {
44+
console.error('Version number not found in README.md');
45+
process.exit(1);
46+
}
47+
48+
const currentVersion = currentVersionMatch[1];
49+
if (currentVersion !== version) {
50+
// バージョン番号を更新
51+
const updatedContent = readmeContent.replace(VERSION_REGEX, `Ver.${version}`);
52+
writeFile(README_PATH, updatedContent);
53+
console.log(`Updated README.md version to ${version}`);
54+
} else {
55+
console.log('Versions are already in sync');
56+
}
57+
}
58+
59+
// スクリプトを実行
60+
updateVersion();

themes/develop/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# テーマ「develop」Ver.0.0.11
2+
3+
## バンドル環境の使い方
4+
5+
### インストール
6+
7+
**themes/develop/** に移動して、下記のコマンドを実行します。実行することでビルドに必要なツールなどがインストールされます。
8+
9+
```bash
10+
$ npm install
11+
```
12+
13+
### ビルドコマンド
14+
15+
#### 本番用ビルド
16+
17+
cssのbuildとjsのbuildを行います。 **納品時にはこのコマンドを実行して納品してください。** JavaScriptが productionビルド となります。
18+
19+
```bash
20+
$ npm run build
21+
```
22+
23+
#### 開発用ビルド
24+
25+
以下のコマンドを実行すると、cssとjsの変更をwatchしてビルドを行います。余分なコードが入ったり、最適化されないため**納品時には必ず npm run build **しましょう。
26+
27+
```bash
28+
$ npm run dev
29+
```
30+
31+
32+
## 組み込みJSの読み込みについて
33+
34+
JavaScriptは、**include/head/js.html** で読んでいます。
35+
developテーマではパフォーマンス向上のために、**Touch_SessionWithContribution**を使って、投稿者以上以上の場合だけ読み込むようにしています。
36+
37+
```html
38+
<!-- BEGIN_MODULE Touch_SessionWithContribution -->
39+
<script src="%{JS_LIB_JQUERY_DIR}jquery-%{JS_LIB_JQUERY_DIR_VERSION}.min.js" charset="UTF-8"></script><!-- BEGIN_MODULE Js -->
40+
<script src="/acms.js{arguments}" charset="UTF-8" id="acms-js"></script><!-- END_MODULE Js -->
41+
<!-- END_MODULE Touch_SessionWithContribution -->
42+
```
43+
44+
組み込みJSを読まないようにすると、スライダーや、画像ビューワーなどの組み込みJSが動作しなくなりますが、一部のよく利用する組み込みJSをsrc/js/lib/buildIn/に実装し、src/js/main.jsで読み込んでいます。
45+
46+
```javascript
47+
import {
48+
// 組み込みJS
49+
} from './lib/buildIn/';
50+
```
51+
52+
これ以外に必要な機能やライブラリは、自分でインストール、実装する必要があります。
53+
バンドル環境が整っていますので、 npm経由でライブラリをもってきて、 importする方式をお勧めします。以下 lazy load を実装する例になります。
54+
55+
```bash
56+
$ npm i vanilla-lazyload
57+
```
58+
59+
```javascript
60+
import LazyLoad from 'vanilla-lazyload';
61+
62+
domContentLoaded(() => {
63+
new LazyLoad({elements_selector: '.js-lazy-load'});
64+
});
65+
```

themes/develop/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"smartphoto": "^1.6.5"
4949
},
5050
"optionalDependencies": {
51-
"@rollup/rollup-linux-x64-gnu": "4.6.1"
51+
"@rollup/rollup-linux-x64-gnu": "4.6.1",
52+
"@tailwindcss/oxide-linux-x64-gnu": "^4.0.1"
5253
}
5354
}

themes/develop/src/js/lib/buildIn/validator/types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import * as rules from './rules';
1313
* @property {function(ValidationResult[], HTMLElement): void} onInvalid - バリデーション失敗時のコールバック関数
1414
* @property {function(ValidationResult[], HTMLElement): void} onValidated - バリデーション後に実行されるコールバック関数
1515
* @property {'onBlur' | 'onChange' | false} shouldValidate - バリデーションのタイミング
16+
* @property {'onBlur' | 'onChange' | false} shouldRevalidate - 再バリデーションのタイミング
1617
* @property {boolean} shouldValidateOnSubmit - 送信時にバリデーションを実行するかどうか
1718
* @property {Record<string, ValidationRule>} customRules - カスタムバリデーションルール
1819
*/

0 commit comments

Comments
 (0)