Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Новый участник


Сообщения: 9
Благодарности: 0

Профиль | Сайт | Отправить PM | Цитировать


В общем разобрался, вот результаты:
Вывод консоли

C:\Users\1234\Desktop\projects>git clone https://github.com/ZerdoX-x/project.git
Cloning into 'project'...
remote: Enumerating objects: 15468, done.
remote: Counting objects: 100% (15468/15468), done.
remote: Compressing objects: 100% (10696/10696), done.
remote: Total 15468 (delta 4201), reused 15463 (delta 4196), pack-reused 0
Receiving objects: 100% (15468/15468), 16.17 MiB | 6.92 MiB/s, done.
Resolving deltas: 100% (4201/4201), done.

C:\Users\1234\Desktop\projects>set /P project_name="Project Name is - "
Project Name is - test

C:\Users\1234\Desktop\projects>Powershell.exe -executionpolicy remotesigned -File script.ps1
Sections: a b c d


Каталог: C:\Users\1234\Desktop\projects\project\src\template


Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 03.08.2019 17:22 71 a.html
-a---- 03.08.2019 17:22 71 b.html
-a---- 03.08.2019 17:22 71 c.html
-a---- 03.08.2019 17:22 71 d.html


Каталог: C:\Users\1234\Desktop\projects\project\src\styles\sections


Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 03.08.2019 17:22 6 a.sass
-a---- 03.08.2019 17:22 6 b.sass
-a---- 03.08.2019 17:22 6 c.sass
-a---- 03.08.2019 17:22 6 d.sass



C:\Users\1234\Desktop\projects>ren "project" "test"

C:\Users\1234\Desktop\projects>ren *.psd "test".psd
Не удается найти указанный файл.

C:\Users\1234\Desktop\projects>move *.psd "test\psd"
Файл с таким именем уже существует
или не найден.

C:\Users\1234\Desktop\projects>cd test

C:\Users\1234\Desktop\projects\test>rd /S /Q .git

C:\Users\1234\Desktop\projects\test>del /F /Q psd\.gitkeep.txt src\fonts\.gitkeep.txt src\img\.gitkeep.txt

C:\Users\1234\Desktop\projects\test>powershell -Command "(gc .\src\index.html) -replace '<title>Title</title>', '<title>test</title>' | Out-File -encoding ASCII index.html"

C:\Users\1234\Desktop\projects\test>Choice /M "Download jQuery?"
Download jQuery? [Y,N]?Y

C:\Users\1234\Desktop\projects\test>If Errorlevel 2 Goto No

C:\Users\1234\Desktop\projects\test>If Errorlevel 1 Goto Yes

C:\Users\1234\Desktop\projects\test>call npm i jquery --save-dev

> node-sass@4.12.0 install C:\Users\1234\Desktop\projects\test\node_modules\node-sass
> node scripts/install.js

Cached binary found at C:\Users\1234\AppData\Roaming\npm-cache\node-sass\4.12.0\win32-x64-72_binding.node

> node-sass@4.12.0 postinstall C:\Users\1234\Desktop\projects\test\node_modules\node-sass
> node scripts/build.js

Binary found at C:\Users\1234\Desktop\projects\test\node_modules\node-sass\vendor\win32-x64-72\binding.node
Testing binary
Binary is fine

> gifsicle@4.0.1 postinstall C:\Users\1234\Desktop\projects\test\node_modules\gifsicle
> node lib/install.js

√ gifsicle pre-build test passed successfully

> jpegtran-bin@4.0.0 postinstall C:\Users\1234\Desktop\projects\test\node_modules\jpegtran-bin
> node lib/install.js

√ jpegtran pre-build test passed successfully

> optipng-bin@5.1.0 postinstall C:\Users\1234\Desktop\projects\test\node_modules\optipng-bin
> node lib/install.js

√ optipng pre-build test passed successfully
npm WARN activebox@1.0.0 No description
npm WARN activebox@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ jquery@3.4.1
added 935 packages from 623 contributors and audited 14350 packages in 59.608s
found 0 vulnerabilities



Код start_project.bat

git clone https://github.com/ZerdoX-x/project.git

set /P project_name="Project Name is - "

Powershell.exe -executionpolicy remotesigned -File script.ps1

ren "project" "%project_name%"

ren *.psd "%project_name%".psd
move *.psd "%project_name%\psd"

cd %project_name%

rd /S /Q .git
del /F /Q psd\.gitkeep.txt src\fonts\.gitkeep.txt src\img\.gitkeep.txt

powershell -Command "(gc .\src\index.html) -replace '<title>Title</title>', '<title>%project_name%</title>' | Out-File -encoding ASCII index.html"

Choice /M "Download jQuery?"
If Errorlevel 2 Goto No
If Errorlevel 1 Goto Yes
Goto End

:No
call npm i
Goto End

:Yes
call npm i jquery --save-dev
cd src\js\
echo //= ../../node_modules/jquery/dist/jquery.min.js > script.js
cd ..\..\
:End

code .


Код script.ps1

param(
[string]$html_path = 'project\src\template\',
[string]$sass_path = 'project\src\styles\sections\',
[string]$html = ".html",
[string]$sass = ".sass"
)

if (!(test-path $html_path)){
write-host Такого пути не существует. Создаем каталог $html_path -for red
mkdir $html_path|out-null
}
if (!(test-path $sass_path)){
write-host Такого пути не существует. Создаем каталог $sass_path -for red
mkdir $sass_path|out-null
}

$sections = read-host "Sections"
[array]$sections = $sections.split()

$sections|ForEach-Object{New-Item -p $html_path -n ("$_"+$html) -it 'file' -v @"
<section id="$_">
<div class="content">

</div>
</section>
"@
}

$sections|ForEach-Object{New-Item -p $sass_path -n ("$_"+$sass) -it 'file' -v @"
#$_

"@
}


Все работает, как и ожидалось. Единственное - консоль сама не закрывается, все равно приходится после открытия vscode закрывать окно консоли вручную, нашел решение, но для меня оно к сожалению не сработало, заменив строку
Код: Выделить весь код
code .
на
Код: Выделить весь код
Start "" "C:\Users\1234\AppData\Local\Programs\Microsoft VS Code\Сode.exe" <.>\.
получаю ошибку 'отказано в доступе':
Скрытый текст



У exe'шника стоят все разрешения и у корневой папки тоже. Пробовал запускать bat с правами администратора, или через cmd (тоже с правами администратора) - результат один. Тут скорее всего проблема в настройках винды, а не в программе которую я пытаюсь запустить. Возможно есть идеи?

Отправлено: 15:35, 03-08-2019 | #16